# Compute horizontal and vertical derivatives

**URL:** <https://scilab.discourse.group/t/compute-horizontal-and-vertical-derivatives/607>\
**Category:** General usage\
**Created:** [August 12, 2024, 11:59am UTC](https://scilab.discourse.group/t/compute-horizontal-and-vertical-derivatives/607 "2024-08-12T11:59:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![QwillDune](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/qwilldune/32/152_2.png) [@QwillDune](https://scilab.discourse.group/u/QwillDune)\
**Post date:** [August 12, 2024, 12:40pm UTC](https://scilab.discourse.group/t/compute-horizontal-and-vertical-derivatives/607/2 "2024-08-12T12:40:02Z")

</div>

Hello,

If I understand correctly, you want to calculate gradients.

See this post

> [@Calculating gradients](https://scilab.discourse.group/t/calculating-gradients/420):
>
> Hi I am wondering if Scilab has a built-in function similar to Python numpy.gradient, which takes an ‘edge-order’ … I can manually create a first-order gradient function in Scilab like this: function [grad]=dydx(y, x) k = length(x); grad = zeros(k); // initialize grad(1) = (y(2) - y(1))./(x(2) - x(1)); grad(k) = (y(k) - y(k-1))./(x(k) - x(k-1)); if k\>2 then // for i = 2:k-1 do // grad(i) = ( (y(i+1) - y(i))./(x(i+1) - x(i)) + .. // …

BR  
François

---

_[View the full topic](https://scilab.discourse.group/t/compute-horizontal-and-vertical-derivatives/607)._
