matlab horzcat CAT arguments dimensions are not consistent.
Show older comments
im using a matrix DATA with dimensions<245x2 double>
then
SECOND = DATA(:,2) >= 8 & DATA(:,2) <= 65 FIRST = DATA(:,1) & SECOND
how can i make them the same dimension so i can merge them in
TDOT = [DATA(FIRST,1) DATA(SECOND,2)]
Accepted Answer
More Answers (1)
Geoff Hayes
on 29 Aug 2014
Saúl - if you want to merge the two matrices as shown above (horizontally), the two matrices must have the same number of rows. So either remove one row from the second matrix (since it has 73 rows) or just add a row of zeros to the first matrix
TDOT = [ [DATA(FIRST,1);0] DATA(SECOND,2) ]
Try the above and see what happens!
2 Comments
Saúl
on 29 Aug 2014
Geoff Hayes
on 29 Aug 2014
My mistake, I hand't read the question closely enough. I'm not sure why the above code would set FIRST to one element less than SECOND. I suppose that you could figure out which row is being removed from FIRST by comparing it with SECOND. They both should have ones and zeros in the same place, except for one index where FIRST would have a zero and SECOND a one.
But do you really need both a FIRST and SECOND, since FIRST is supposed to take the only the values that match those from SECOND.
Your code could simplify to
TDOT = DATA(SECOND,:);
which would mean grab data from both columns where SECOND indicates which rows of the second column meet the specified criteria.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!