Borrar filtros
Borrar filtros

Numel error cant figure out why

1 visualización (últimos 30 días)
Anantha Padmanabhan
Anantha Padmanabhan el 13 de Oct. de 2014
Respondida: Roger Stafford el 14 de Oct. de 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

Respuestas (1)

Roger Stafford
Roger Stafford el 14 de Oct. de 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.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by