Getting error as array indices must be positive integers or logical values in slope calculation.
Show older comments
My R matrix is 512x43 and I would like to calculate slope by central diff from row wise values.
It shows logical values error ? What's the wrong in this slope calculation.
Thanks in advance.
%testing slope by central difference
load('R.mat');
dy = zeros(43,1);
ddy = zeros(43,1);
delx = 1e-4;
for ij=1:1:512
for ji = 1:1:43
dy(ij,ji) = (R(ij,ji+1)-R(ij,ji-1))/(2/delx);
ddy(ij,ji) = (R(ij,ji+1)-2*R(ij,ji)+R(ij,ji-1))/delx^2;
end
end
2 Comments
Walter Roberson
on 15 Sep 2021
R(ij,ji-1)
What's that when ji is 1?
Ramesh Bala
on 15 Sep 2021
Accepted Answer
More Answers (1)
Image Analyst
on 15 Sep 2021
1 vote
A thorough discussion of the error is in the FAQ:
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!