演算処理した結果を配​列にします。配列は毎​回サイズが異なる。回​数はN回とし、これを​for文処理したい。

3 views (last 30 days)
章 佐々木
章 佐々木 on 4 Nov 2021
Commented: 章 佐々木 on 8 Nov 2021
A1=演算処理
A2=演算処理
   ・
   ・
An=演算処理
これを
for 1:n
  ????
end

Answers (1)

Atsushi Ueno
Atsushi Ueno on 4 Nov 2021
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
result = 1×5
3 7 11 15 19
  2 Comments
章 佐々木
章 佐々木 on 8 Nov 2021
ありがとうございました。参考なりました。

Sign in to comment.

Categories

Find more on ループと条件付きステートメント in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!