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!