필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How do you rearragne a matrix?

조회 수: 1 (최근 30일)
KieranSQ
KieranSQ 2019년 8월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
I am trying to vectorise a matrix of by using the data:
AN=[0,0.500000000000000,0,0.500000000000000,0.500000000000000,0,0,0.500000000000000,0,0.500000000000000,1,0.500000000000000,0,0.500000000000000,0.500000000000000,0.500000000000000,1,0.500000000000000,0.500000000000000,1,1,0.500000000000000,1,1;0,0,0.500000000000000,0,0.500000000000000,0.500000000000000,0.500000000000000,0.500000000000000,1,0.500000000000000,0.500000000000000,1,1,0.500000000000000,1,0,0,0.500000000000000,1,0.500000000000000,1,0.500000000000000,0,0.500000000000000]
Then I want to produce a 2x16 matrix where by
TEMP = [AN(1,3:3:end)-AN(1,1:3:end),AN(2,3:3:end)-AN(2,1:3:end);AN(1,2:3:end)-AN(1,1:3:end),AN(2,2:3:end)-AN(2,1:3:end)]
gives me a 2x16 matrix with the first two rows (1:2,:) being matrix 1 and the next set (3:4,:) being matrix 2 and so on. I have tried reshape but have failed to get this working. I want something like this, where 1) is the matrix number:
0 0.5
0.5 0
-0.5 0.5
0 0.5
. .
. .
. .
0.5 0
0.5 -0.5
Any advice would be appreciated. I am trying to avoid for loops for speed as my matricies become extremely large.

답변 (1개)

Athul Prakash
Athul Prakash 2019년 8월 19일
After the 2 lines of code above, use
res = reshape(TEMP, [16 2])
See the documentation here:
(The code shown above produces the exact same output you mentioned in your question.)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by