in the below mentioned code, i get an error in finding some elements (not in all) : 0×1 empty double column vector
Afficher commentaires plus anciens
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)
Réponse acceptée
Plus de réponses (1)
k = find(abs(x-0.3)==min(abs(x-0.3)))
2 commentaires
ravi shukla
le 15 Août 2023
Asking for strict equality of expressions is dangerous because of floating point arithmetic. See @Steven Lord 's answer for a more detailed explanation.
Catégories
En savoir plus sur Vehicle Dynamics Blockset dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!