필터 지우기
필터 지우기

How to specify an exact value of variable in (For Loop)

조회 수: 2 (최근 30일)
Ali Tawfik
Ali Tawfik 2019년 7월 12일
댓글: Ali Tawfik 2019년 7월 12일
Hi all,
I am doing a for loop, but I am wondering how can I extract/specify a value of x when i =2 or 3?, the x now has 3 different values, how can I extract a specific value.
for i=1:3
x=i+2
end
Thanks,

채택된 답변

Walter Roberson
Walter Roberson 2019년 7월 12일
for i=1:3
x(i)=i+2;
end
x(2:3)
  댓글 수: 1
Ali Tawfik
Ali Tawfik 2019년 7월 12일
Hi,
Thanks for your prompt reply.
I have been trying the same for the following commands, but I could not, and got that error, (I got that error, Subscript indices must either be real positive integers or logicals.),
for i=[90,30,-30]
theta(i)=i*pi/180
end
& also, when type length of (i) it equals =-30, how ?, and I have 3 variables ?
actually, I hope to have 3 variables (one at i =90, and another =30, and so on ]
So please could you tell me how could I do this ?
Thanks,

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

추가 답변 (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