For loops in Matlab

조회 수: 5 (최근 30일)
UTS
UTS 2014년 1월 18일
댓글: UTS 2014년 1월 18일
C=[ ];
for A=1:4
B=[5 10 5 10];
end
C=[A,B]
for example :
A=1:4
and
B=[5 10 5 10]
if A==1 & 3 then B==5, and when A==2&4 B==10
A B
1 5
2 10
3 5
4 10
How we could use Matlab code to obtain the above loop as shown in the picture, Thank you in advance for your assistance,

채택된 답변

Amit
Amit 2014년 1월 18일
편집: Amit 2014년 1월 18일
I think simple doing
C = [A' B'];
would work. You dont need to do this in a loop.
  댓글 수: 5
Amit
Amit 2014년 1월 18일
편집: Amit 2014년 1월 18일
Okay, that's the problem.
What I said was to do is:
B = [5,10,5,10];
A = 1:4;
C = [A' B'];
Than simple. No loops, nothing.
UTS
UTS 2014년 1월 18일
Thank you very much C =
1 5
2 10
3 5
4 10

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

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