How to Store results of While-Loop in MATLAB?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Mischa Kim
2016-9-18
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!