Re-arranging huge martix

Hi guys, spent long time trying to figure out how to rearange the matrix that I have, what am having is the following martix
A= [ x1 y1 x2 y2 x3 y3 ; x4 y4 x5 y5 x6 y6]
am trying to arrange my matrix into the following form B = [x1 y1 ; x2 y2 ; x3 y3 ; ....]
my original matrix is (10,1300) am trying to convert it to (6500,2)
i have tried to use for loop but it did not work out
here is my script
A = input('enter mat>');
rowA= size(A,1);
colA= size(A,2);
n=numel(A)/2;
for i=1:1:rowA
for j=1:2:colA-1
B = A(i,[j,j+1])
%continue
end
end
please i need something more efficient and faster than for loops!
Thanks
Morgan

 Akzeptierte Antwort

Jan
Jan am 21 Mär. 2012

0 Stimmen

B = transpose(reshape(transpose(A), 2, []));

4 Kommentare

Morgan
Morgan am 21 Mär. 2012
Thank you Jan
I really apreciate it
Morgan
Image Analyst
Image Analyst am 21 Mär. 2012
By the way, a 13000 element array is not huge anymore. A garden variety digital image will be 300 times that size.
Geoff
Geoff am 22 Mär. 2012
It's pretty huge, considering you have to type the whole thing in at that prompt. ;-)
Jan
Jan am 22 Mär. 2012
You can let the java robot do the typing for you. Then it is small again.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Sparse Matrices finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 21 Mär. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by