identifying the elements of a cell
Show older comments
I have a 700x8 cell, with each cell having a matrix 6x2 in size. I want to get the first row of each cell. How do I perform this?
Accepted Answer
More Answers (1)
Sammit Jain
on 10 Jul 2018
Hi, This seems to be a simple case of cell indexing.
Let's call your original cell array (of cells) 'mainCellArray'
Now, let's have allRowsArray = [mainCellArray{:}] Then, firstRowArray = [allRowsArray{1,:}]
Essentially, we're first re-arranging the contents of the main cell array, stacking them one next to the other, then we just index the first row.
Here's what the code should look like:
allRowsArray = [mainCellArray{:}];
firstRowArray = [allRowsArray{1,:}]
Hope this helps. If in case you want to pick a different combination of rows/columns, then just try to transpose these concatenations and see if you get what you want.
Cheers.
Categories
Find more on Matrix Indexing 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!