Reputation: 1221
I find that gradient function in matlab gives me different answer from my expectation.
I tested this dataset
a = [0.337961000000000 0.394426000000000 1.083110000000000;
0.337977000000000 0.394627000000000 1.084470000000000;
0.337972000000000 0.394768000000000 1.085870000000000;
0.337950000000000 0.394923000000000 1.087260000000000;
0.337949000000000 0.395092000000000 1.088510000000000]
According to the way used to calculate gradient
v(2,:) = (a(3,:)-a(1,:))/(2*dt)
where dt = 1/240;
I expect v(2,:) can be
0.001319999999998 0.041039999999994 0.331200000000011
while gradient function (gradient(a)/dt) give
1.0e+02 *
0.135960000000000 0.895791600000000 1.655623200000000
Can anyone please help to see what is wrong here? Thank you.
Upvotes: 1
Views: 79
Reputation: 1456
you are looking at the wrong orientation of the gradient, you need to use the second output of gradient.
For example:
[~, fy] = gradient(a);
fy = fy / dt;
fy(2,:)
ans =
0.0013 0.0410 0.3312
Upvotes: 2