for loop in matrix names (Syntax)

조회 수: 1 (최근 30일)
ARS
ARS 2012년 7월 10일
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에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by