How to Store results of While-Loop in MATLAB?
Afficher commentaires plus anciens

clc
clear all
x1=19;% Starting Point on X-Axis
x2=288;% Ending Point on X-Axis
y1=38;% Starting Point on Y-Axis
y2=240;% Ending Point on Y-Axis
dx=x2-x1% Change in X
dy=y2-y1% Change in Y
if abs(dx)>abs(dy);
ST=abs(dx)
else
ST=abs(dy)
end
dx=dx/ST
dy=dy/ST
xi=x1+dx;
yi=y1+dy;
X=xi
Y=yi
while 'Set Pixel at X, Y'
X=X+dx
Y=Y+dy
if X>[x2-1]
break
end
end
Réponses (1)
Mischa Kim
le 18 Sep 2016
Muhammad,
x1=19;% Starting Point on X-Axis
x2=288;% Ending Point on X-Axis
y1=38;% Starting Point on Y-Axis
y2=240;% Ending Point on Y-Axis
dx=x2-x1% Change in X
dy=y2-y1% Change in Y
if abs(dx)>abs(dy);
ST=abs(dx)
else
ST=abs(dy)
end
dx=dx/ST
dy=dy/ST
xi=x1+dx;
yi=y1+dy;
ii = 1;
X(ii) = xi;
Y(ii) = yi;
while true %'Set Pixel at X, Y'
ii = ii + 1;
X(ii) = X(ii-1) + dx;
Y(ii) = Y(ii-1) + dy;
if X(ii) > (x2-1)
break
end
end
Catégories
En savoir plus sur Sparse Matrices 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!