필터 지우기
필터 지우기

Convert a 3 variable array to a 2 variable array

조회 수: 2 (최근 30일)
Anson Hancock
Anson Hancock 2015년 8월 11일
편집: Matt J 2015년 8월 11일
I have a 2x25x11 array of x,y coordinates for tracked points through an image sequence (11 total points in all). I want to convert this to a 22x11 double where, for each pair of columns, the even number column = the x coordinate of the point and the odd number column = the y coordinate of the point. When I have used the transpose function on a single point I get the desired result
example: transpose(a(:,:,1))
But otherwise I have been unable to get this result in one go for the entire array. Any help would be greatly appreciated. Let me know if you need any clarification or additional info.
  댓글 수: 3
Star Strider
Star Strider 2015년 8월 11일
Your array is 2 rows by 25 columns by 11 ‘pages’.
How do you want to map the (2x25) into 22?
Anson Hancock
Anson Hancock 2015년 8월 11일
편집: Anson Hancock 2015년 8월 11일
So I have figured out the basic code to do what I want, it looks something like this:
test = transpose(([pts(1,:,1);pts(2,:,1);pts(1,:,2);pts(2,:,2)...]));
But is there any way of setting up so that it does this for all the "n" number of "pages" in one go?

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

채택된 답변

Matt J
Matt J 2015년 8월 11일
편집: Matt J 2015년 8월 11일
test=permute(pts,[2,1,3]);
test=reshape(test,size(pts,2),[]);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by