Setting matrix with functions or for loop

조회 수: 1 (최근 30일)
abuzer
abuzer 2012년 3월 6일
I have a matrix as A=[1 3 5 8; 9 10 12 25; 32 21 45 65; 2 37 17 2] and I want to change places of them, B=[1 3 5 8 9 10 12 25;32 21 45 65 2 37 17 2] how can I make this code with for loop? and after this settings,I want to write this matrix to text file with tab between coloums..please help

채택된 답변

Matt Tearle
Matt Tearle 2012년 3월 6일
How general does this need to be? And why do you want to use a loop specifically? This does what you're asking, and would generalize to any number of rows (as long as it's even):
B = [A(1:2:end,:),A(2:2:end,:)]
dlmwrite('filename.txt',B,'\t')
  댓글 수: 1
abuzer
abuzer 2012년 3월 6일
thank you so much.. I am beginner of Matlab.I supposed solution would be with loop..Greetings

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

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