is this allowed in a forloop

조회 수: 1 (최근 30일)
Doubutsu
Doubutsu 2014년 5월 7일
댓글: Doubutsu 2014년 5월 12일
I have the following code and I just wonderend if it was allowed to do something like this.
for i=[1:11 10:-1:1]
for j=1:2
for k=[6:11 10:-1:1 2:6]
for g=1:21
FXcross1(g)=(dly(g).*BZ(i,j,k)-dlz(g).*BY(i,j,k))*I;
end
end
end
end
I mean for the i and the k, nog for the j and the g. Can you do something like that. Since I want to acces, for k, the indexnumbers 6 7 8 9 10 11 10 9 8 7 6 5 4 3 2 1 2 3 4 5 6.
thanks in advance
  댓글 수: 2
Roberto
Roberto 2014년 5월 7일
Please format your code, here is great tutorial! your code is unreadable!
Doubutsu
Doubutsu 2014년 5월 7일
@ Roberto: thanks for saying, I had not noticed XD

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

채택된 답변

Roberto
Roberto 2014년 5월 7일
편집: Roberto 2014년 5월 7일
I don't see why not! only, are these valid arguments for your functions/subscripts? try to run it! but I think is perfectly valid!
  댓글 수: 1
Doubutsu
Doubutsu 2014년 5월 12일
yeah it worked. I did something else wrong and because of that thought that my for loop was not valid XD. 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