in the below mentioned code, i get an error in finding some elements (not in all) : 0×1 empty double column vector
Show older comments
m=41;
n=51;
dx=0.0500;
dy=0.0500;
for i=1:m
for j=1:n
x(i,1)=(i-1)*dx;
y(j,1)=(j-1)*dy;
end
end
k=find(x==0.3)
Accepted Answer
More Answers (1)
k = find(abs(x-0.3)==min(abs(x-0.3)))
2 Comments
ravi shukla
on 15 Aug 2023
Asking for strict equality of expressions is dangerous because of floating point arithmetic. See @Steven Lord 's answer for a more detailed explanation.
Categories
Find more on Vehicle Dynamics Blockset 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!