필터 지우기
필터 지우기

How can I create variables with for loop?

조회 수: 10 (최근 30일)
muly san
muly san 2013년 8월 15일
I want somthing like this:
for i=1:3;
j`i'=i;
end
The output shuld be:
j1=1 j2=2 j3=3
thanks!

답변 (3개)

James Tursa
James Tursa 2013년 8월 15일

Image Analyst
Image Analyst 2013년 8월 15일

Ilham Hardy
Ilham Hardy 2013년 8월 15일
편집: Ilham Hardy 2013년 8월 15일
Use eval
To know more about eval function, type doc eval in your command window.
To know more about why you should avoid eval, wait an pay attention to comment on this answer :P
  댓글 수: 1
Jan
Jan 2013년 8월 15일
Oh no, Ilham Hardy, do not suggest eval() never ever and under no circumstances. It is evil and eats up the programmers trials to write clear, clean and efficient code. There is always a better solutions. The topic has been discussed often enough and is found in the FAQs.
Satisfied? :-)

댓글을 달려면 로그인하십시오.

카테고리

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