フィルターのクリア

reduce vector each loop

6 ビュー (過去 30 日間)
Ali Tawfik
Ali Tawfik 2020 年 6 月 4 日
編集済み: Ali Tawfik 2020 年 6 月 5 日
I am trying to reduce the vector length backward each loop, like the following: I think I should use for loop but i can not figure out how to do it
x=0:.1:1;
x=0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0;
Then I would like the OUTPUT to be
x(1)= 0 .1 .2 .3 .4 .5 .6 .7 .8 .9
x(2)= 0 .1 .2 .3 .4 .5 .6 .7 .8
x(3)= 0 .1 .2 .3 .4 .5 .6 .7
.. ..
and so on.. until I reach to x(11)=0

採用された回答

madhan ravi
madhan ravi 2020 年 6 月 4 日
The end indexing inside the loop would be total number of elements in x minus iterator.
  3 件のコメント
madhan ravi
madhan ravi 2020 年 6 月 4 日
x = 0:.5:1;
N = numel(x);
Wanted = cell(N,1);
for ii = 1:N
Wanted{ii} = x(1: (N - ii)+1);
end
celldisp(Wanted)
Ali Tawfik
Ali Tawfik 2020 年 6 月 5 日
編集済み: Ali Tawfik 2020 年 6 月 5 日
x=0:0.1:1;
for i=1:length(x)
x(1:(11-i)+1) % so the addition of one here to aviod make 1:0
end
thank you

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

その他の回答 (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