for loop in matrix names (Syntax)

1 次查看(过去 30 天)
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.

采纳的回答

Honglei Chen
Honglei Chen 2012-7-10
  2 个评论
ARS
ARS 2012-7-10
Thanks Honglei Chen.
Jan
Jan 2012-7-10
@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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by