swap x and y axis in a matrix

조회 수: 33 (최근 30일)
Maryam Hamrahi
Maryam Hamrahi 2016년 5월 31일
답변: Jos (10584) 2016년 5월 31일
I would like to swap x and y axis in a matrix with n rows and two columns.
I have [r1 r2] and I would like to convert it to [r2 r1]
Thanks in advance for any answers!

채택된 답변

Jos (10584)
Jos (10584) 2016년 5월 31일
M = [1 10 ; 2 20 ; 3 30]
Mnew = M(:,[2 1]) % by far the easiest
New = fliplr(M)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by