Filter löschen
Filter löschen

Numel error cant figure out why

1 Ansicht (letzte 30 Tage)
Anantha Padmanabhan
Anantha Padmanabhan am 13 Okt. 2014
Beantwortet: Roger Stafford am 14 Okt. 2014
for i=1:1:randomvariableforx1secondpoint
if actualshrtestdistancepoint2==distancepointfromotherpointsecondpoint(i)
pointtouse2haha=i;
break;
else ('hahaha no');
end
end
pointtouse2=pointtouse2haha;
% distancepointfromotherpointlel2=sqrt(((xlocation1secondpoint(pointtouse2)/10)-p2x)^2+((ylocation1secondpoint(pointtouse2)/10)-p2y)^2);
% distancepointfromotherpoint2=min(distancepointfromotherpointlel2)
%% newxlocationonsecondlinelel=xlocation1(pointtouse2)/10;
newylocationonsecondlinelel=ylocation1(pointtouse2)/10;
So my variable "randomvariableforx1secondpoint" is 48 and i find the maximum value at 37. so i wanted to use this position of i but for some reason my code uses the value of 48 in the foollowing steps and i get a numel error. can you guys help out? thanks

Antworten (1)

Roger Stafford
Roger Stafford am 14 Okt. 2014
It looks as though the exact equality demanded by "==" never occurred and so the 'break' did not happen, but your value of 'pointtouse2haha' had previously been set to 48 before the for-loop. Remember, "==" requires precise equality, not just equality within some given tolerance.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by