separating non empty array

2 views (last 30 days)
jaffa
jaffa on 5 Sep 2014
Edited: per isakson on 5 Sep 2014
i'm noob to matlab, I have a matrix of 1764 x1 this was concatenated from 2 images how can i create a new matrix where it will automatically split into 2 columns of 882 x2?
example
b=[b;c] % this give me 1764 x 1
i tried
c=[c,b] but it will only give me 882 x1 double instead of 882 x 2
any expert advise is greatly appreciated.
  2 Comments
per isakson
per isakson on 5 Sep 2014
Edited: per isakson on 5 Sep 2014
You are using the letters a, b and c in a confusing way! Is a in the second line the same as a in the first?
jaffa
jaffa on 5 Sep 2014
thanks for replying my answer. let me explain this in more details:
what i need help is to split the concatenation.example as follows:
all_vect=[all_vect;feat_vect];
% i'm concatenating 2 images into all_vect vertically which is 1764 x 1 double
what i'm trying to do now is to split this 1764 x 1 into 884 x 2 double
and i have tried this command which is not working:
splitvect=[splitvect,all_vect];
please advise

Sign in to comment.

Answers (2)

dpb
dpb on 5 Sep 2014
a=[b c];
The ';' caused vertical concatenation; a ',' or space is horizontal. Read the "Getting Started" section on basic manipulations in Matlab...
There's a tutorial link on 'Matrices and Arrays' under which is another link specifically on 'Concatenation'. I urge you to just begin at the beginning and work thru the tutorial info to get a handle on the basics...it'll be much quicker route than posting and waiting...
  1 Comment
jaffa
jaffa on 5 Sep 2014
Edited: jaffa on 5 Sep 2014
i understand the concatenation guide but what i need help is how to split the concatenation.
all_vect=[all_vect;feat_vect];
% i'm concatenating 2 images into all_vect vertically which is 1764 x 1 double
what i'm trying to do is to split this 1764 x 1 into 884 x 2 double i tried this command:
splitvect=[splitvect,all_vect];
please advise

Sign in to comment.


per isakson
per isakson on 5 Sep 2014
Edited: per isakson on 5 Sep 2014
"what i'm trying to do now is to split this 1764 x 1 into 884 x 2 double"
This does it
long_vector = linspace( 1, 12, 1764 ); % sample vector
two_row_array = reshape( long_vector, [], 2 );
and check the result
>> whos
Name Size Bytes Class Attributes
long_vector 1x1764 14112 double
two_row_array 882x2 14112 double
The word "split"&nbsp is not a good one to describe this operation. And don't forget dpb's advise regarding Getting Started.
&nbsp
Correction
The name, two_row_array, should be two_col_array

Community Treasure Hunt

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

Start Hunting!