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

A1=演算処理
A2=演算処理
   ・
   ・
An=演算処理
これを
for 1:n
  ????
end

Respuestas (1)

Atsushi Ueno
Atsushi Ueno el 4 de Nov. de 2021

0 votos

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 comentarios

章 佐々木
章 佐々木 el 8 de Nov. de 2021
ありがとうございました。参考なりました。

Iniciar sesión para comentar.

Categorías

Productos

Versión

R2020a

Etiquetas

Preguntada:

el 4 de Nov. de 2021

Comentada:

el 8 de Nov. de 2021

Community Treasure Hunt

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

Start Hunting!