MATLAB Answers

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Loop iteration filling an array

1 ビュー (過去 30 日間)
luca
luca 2019 年 10 月 10 日
終了済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi, I have a code with the following structure
for i= 1:7
....
GGG= ....
if i==1
NEXTse= GGG
AAA = NEXTse
elseif i>1
NEXTse = GGG
AAA = [SETT,[NEXTse(1,:);SETT(2,end)+cumsum(diff([0,NEXTse(2,:)]))];
end
SETT=AAA;
end
My objective is to create an array SETT that after seven iteration collect all the value of GGG . During the first iteration I form an array AAA that collect GGG and then I insert it in SETT before pass to i=2.
Then at i=2, I attach to the previous SETT the new GGG through
AAA = [SETT,[NEXTse(1,:);SETT(2,end)+cumsum(diff([0,NEXTse(2,:)]))];
at i= 3 I attach again the GGG created in the third iteration to the previous 2.
I don't know why but the program gives me error, May someone told me why this logic is wrong?
  2 件のコメント
luca
luca 2019 年 10 月 10 日
I correct it now

回答 (1 件)

prasanth s
prasanth s 2019 年 10 月 10 日
you have used semicolom at the middle of 'AAA = [SETT,[NEXTse(1 ........' code. so may be the size did not matching. try using colon.

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by