Borrar filtros
Borrar filtros

Is it possible with for loop s1,s2,s3 variable looping ?

1 visualización (últimos 30 días)
x y
x y el 30 de Oct. de 2015
Editada: per isakson el 30 de Oct. de 2015
Hy I wonder it is possible something this (looping with variable name) :
s1 = 5;
s2 = 6;
s3 = 7;
for i = 1:3
s[(i)] or s(i)
end
  1 comentario
Geoff Hayes
Geoff Hayes el 30 de Oct. de 2015
xy - why not just store your three variables in an array as
s = [5 6 7];
and then access each element as
for k = 1:3
% do something with s(k)
end

Iniciar sesión para comentar.

Respuesta aceptada

per isakson
per isakson el 30 de Oct. de 2015
Editada: per isakson el 30 de Oct. de 2015

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by