For loop with multiple variables

8 visualizaciones (últimos 30 días)
Ryosuke Saito
Ryosuke Saito el 12 de Abr. de 2020
Comentada: Ryosuke Saito el 12 de Abr. de 2020
Why does this not success??
values_1=[1 2]
values_2=[2 3]
values_3=[3 4]
values_4=[4 5]
values_5=[5 6]
for i=1:5
X = num2str(i)
values_'X'a(i,:)=sum(values_'X'(i,:),2);
end
I'd like to do this using by for loop:
values_1a(i,:)=sum(values_1(i,:),2);
values_2a(i,:)=sum(values_2(i,:),2);
values_3a(i,:)=sum(values_3(i,:),2);
values_4a(i,:)=sum(values_4(i,:),2);
values_5a(i,:)=sum(values_5(i,:),2);
  4 comentarios
Ryosuke Saito
Ryosuke Saito el 12 de Abr. de 2020
Oh thanks. I understood.

Iniciar sesión para comentar.

Respuestas (1)

Mehmed Saad
Mehmed Saad el 12 de Abr. de 2020
eval Function (Not Recommended) but it will do what you are trying here

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by