演算処理した結果を配列にします。配列は毎回サイズが異なる。回数はN回とし、これをfor文処理したい。
Mostra commenti meno recenti
A1=演算処理
A2=演算処理
・
・
An=演算処理
これを
for 1:n
????
end
Risposte (1)
n = 5;
A1 = 1 + 2; % = 3
A2 = 3 + 4; % = 7
A3 = 5 + 6; % = 11
A4 = 7 + 8; % = 15
A5 = 9 + 10;% = 19
result = [];
for i = 1:n
eval(['result = [result A' num2str(i) '];']);
end
result
2 Commenti
Atsushi Ueno
il 4 Nov 2021
result = [];
for i = 1:n
eval(['result(end + 1) = A' num2str(i) ';']); % 最近話題の技、こっちの方が速い
end
end + 1 の技については下記のツイートを参考にさせて頂きました。
章 佐々木
il 8 Nov 2021
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!