필터 지우기
필터 지우기

Sequence of adding numbers

조회 수: 1 (최근 30일)
Akmyrat
Akmyrat 2014년 6월 11일
편집: José-Luis 2014년 6월 11일
Hi i have like this question. Lets say i have this code : for i=1:4 C=2+i; end
this gives me this answer: C=3, C=4,C=5,C=6
BUT I want like this answer: C1=3, C2=4, C3=5, C4=6, which is with numbers after letter C. Can anyone help please...thanks :)

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 6월 11일
편집: Azzi Abdelmalek 2014년 6월 11일
  댓글 수: 1
Akmyrat
Akmyrat 2014년 6월 11일
thanks a lot Azzi Abdelmalek...

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

추가 답변 (1개)

José-Luis
José-Luis 2014년 6월 11일
편집: José-Luis 2014년 6월 11일
It might better if you put all your results in one array. Perhaps like this:
ii = 1:4;
C = NaN*ones(size(ii));
for idx = ii
C(idx) = 2 + idx;
end
Creating variables names dynamically, as you seem to want to do, is a bad idea.
Without a loop:
C = 1:4;
C = C + 2;
  댓글 수: 1
Akmyrat
Akmyrat 2014년 6월 11일
thanks a lot Jose-Luis..

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by