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

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

Categories

Products

Release

R2020a

Asked:

on 4 Nov 2021

Commented:

on 8 Nov 2021

Community Treasure Hunt

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

Start Hunting!