How to extract contents from cell array
10 views (last 30 days)
Show older comments
Hi,
I have a cell array that looks like this:
xdata =
[1x51 double]
[1x51 double]
[1x51 double]
[1x51 double]
ydata =
[1x51 double]
[1x51 double]
[1x51 double]
[1x51 double]
which I extracted from Matlab figure files. How can I see the contents in the xdata and ydata?
Thanks a lot for your help
0 Comments
Answers (2)
Cedric
on 22 Jan 2013
Edited: Cedric
on 22 Jan 2013
A few other ways:
>> xdata{:}
or
>> cellfun(@(a)disp(a), xdata)
The content of cell #3, for example, of xdata can be accessed this way:
>> xdata{3}
it is a 1x51 numeric array, whose elements can be indexed, e.g. element #7 of cell #3 can be accessed this way:
>> xdata{3}(7)
3 Comments
Cedric
on 23 Jan 2013
Edited: Cedric
on 23 Jan 2013
Actually Matt gave you the answer with the double-click. If you wanted to open cells one by one, you could type the following in the command line:
>> xdata{1}
and see that you are displaying the content of cell #1 of xdata (you can do the same with cells #2 to #4, and also the same with ydata). Then, based on Matt answer, you could type the following in the command window:
>> openvar xdata{1}
and observe that you have the same content, but this time in a spreadsheet. From there you can e.g. cut and paste into Excel.
If you wanted to automatize the export to Excel, you could try to build something based on xlswrite(). If you want to learn more, type the following in the command window:
>> doc xlswrite
but you will have to understand how to deal properly with cell arrays first I guess.
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!