Splitting an array?
2 views (last 30 days)
Show older comments
Hello everybody. Here is the issue.. having the array C{1,1} I normally don’t know the exact number of rows. How can I split that matrix in 2 parts?, I can use :
o = (C{1,1}(:,[1:end/2]));
to split the first part, however the second part is not that easy because the number of rows varies at the interior in each ‘C’ array. Thank you.
0 Comments
Accepted Answer
Jan
on 23 Apr 2021
Edited: Jan
on 23 Apr 2021
Data = C{1,1};
Len = size(Data, 2);
Half = floor(Len / 2);
Part1 = Data(:, 1:Half);
Part2 = Data(:, Half+1:Len);
It is not clear to me, what this means: "second part is not that easy because the number of rows varies at the interior in each ‘C’ array"
By the way, 1:x is a vector already. The square brackets are Matlab concatenation operator. [1:x] concatenates 1:x with nothing and is a waste of time in consequence.
6 Comments
More Answers (0)
See Also
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!