How to Store results of While-Loop in MATLAB?

1 回表示 (過去 30 日間)
Muhammad Nauman
Muhammad Nauman 2016 年 9 月 18 日
回答済み: Mischa Kim 2016 年 9 月 18 日
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

回答 (1 件)

Mischa Kim
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

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by