for loop in matrix names (Syntax)

1 visualización (últimos 30 días)
ARS
ARS el 10 de Jul. de 2012
Hi All,
I want to use a new vector every time in my function using for loop. My code is as follows:
for g=1:40
hac=ret(str2num('g'));
results=nwest(hac,ones(length(hac),1),4);
out{1,g}=results;
end;
I want vector/matrix ret to change as ret1,re2.....ret40. The above code produces error. problem is in line2.
Help will be appreciated.
Regards,
AMD.

Respuesta aceptada

Honglei Chen
Honglei Chen el 10 de Jul. de 2012
  2 comentarios
ARS
ARS el 10 de Jul. de 2012
Thanks Honglei Chen.
Jan
Jan el 10 de Jul. de 2012
@Ahmad: Believe the FAQ and consider, that including an index in the name of the variable is a bad programming practice, while using an index as index is fast, clean and flexible.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by