How to Store results of While-Loop in MATLAB?

1 visualización (últimos 30 días)
Muhammad Nauman
Muhammad Nauman el 18 de Sept. de 2016
Respondida: Mischa Kim el 18 de Sept. de 2016
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

Respuestas (1)

Mischa Kim
Mischa Kim el 18 de Sept. de 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

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by