フィルターのクリア

Varying vector from [0 100] to [100 0]

1 回表示 (過去 30 日間)
Ismaeel Dasti
Ismaeel Dasti 2022 年 7 月 7 日
コメント済み: Ismaeel Dasti 2022 年 7 月 7 日
I have a function that takes a vector as an input. I want to run this function multiple times with a for loop while varying this vector from [0 100] to [100 0]. How can I vary this vector like that? Thank you.
  2 件のコメント
Chunru
Chunru 2022 年 7 月 7 日
Consider moving a point from [0, 100] to [100, 0] on a plane. How do you move it? You have to specify other conditions. For examples, you can mover the point uniformly along an arc on a circle, or a straight line between the 2 points.
Specfify your requirements first.
Ismaeel Dasti
Ismaeel Dasti 2022 年 7 月 7 日
It would be a straight line.

サインインしてコメントする。

採用された回答

DGM
DGM 2022 年 7 月 7 日
Maybe something like this?
npoints = 11;
v = linspace(0,100,npoints);
for p = 1:npoints
thisv = [v(p) v(npoints-(p-1))];
myfunction(thisv);
end
  1 件のコメント
Ismaeel Dasti
Ismaeel Dasti 2022 年 7 月 7 日
Wow it worked! Thanks.

サインインしてコメントする。

その他の回答 (1 件)

Chunru
Chunru 2022 年 7 月 7 日
編集済み: Chunru 2022 年 7 月 7 日
p1 = [0 100]; p2 = [100, 0];
dp = (p2-p1)/100;
di = 10; % di=1
for i=0:di:100
p = p1 + i*dp;
fprintf('%3d %3d\n', p)
end
0 100 10 90 20 80 30 70 40 60 50 50 60 40 70 30 80 20 90 10 100 0

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by