How to access data in a cell array
Show older comments
Hi,
I have a cell array of 1x10 where each of the 10 arrays are matrices of 80x31. If I want to access the data of each of the cells but just (2:60,1), how can I access it?
I tried with mycell{1,[2:60,1]} but it doesn't work.
Any help will be very much appreciated.
1 Comment
MANOGNA POTLURI
on 2 Aug 2020
try mycell{1}( data you want to access)
Accepted Answer
More Answers (2)
Image Analyst
on 17 May 2018
Try this. Say you're in a loop over k
for k = 1 : length(mycell)
% Extract the k'th cell's contents.
thisCellContents = mycell{k}; % Will be a 80x31 array.
subArray = thisCellContents(2:60, 1); % Extract columns 2-60 of column 1
% Now do something with subarray.....
end
2 Comments
Auryn_
on 17 May 2018
Image Analyst
on 17 May 2018
surf() is a function. You don't assign anything TO it. That will blow away the surf() function. Bad idea. You CALL the surf() function by passing your data INTO it. See the help.
Alexandra Santos
on 14 Mar 2021
1 vote
I had a similar question but maybe commenting here may be better. Does anyone know how to append array data within within the cell array? I.e. If you were to access your matrix within the cell array and wanted to add a vector to it.
Thanks.
2 Comments
Image Analyst
on 14 Mar 2021
index = 5; % Whatever cell you want to deal with
ca{index} = [ca{index}, yourVector]; % For row vectors. Or use semicolon if they're column vectors.
Alexandra Santos
on 16 Mar 2021
Thank you !!!!
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!