Numel error cant figure out why

1 次查看(过去 30 天)
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

回答(1 个)

Roger Stafford
Roger Stafford 2014-10-14
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.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by