How to extract contents from cell array

9 ビュー (過去 30 日間)
Weijie
Weijie 2013 年 1 月 22 日
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

回答 (2 件)

Cedric
Cedric 2013 年 1 月 22 日
編集済み: Cedric 2013 年 1 月 22 日
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 件のコメント
Weijie
Weijie 2013 年 1 月 23 日
Btw, the data shows up in the command window. Any methods to make them show up in the variable editor instead so that I can choose the cells I want?
Cedric
Cedric 2013 年 1 月 23 日
編集済み: Cedric 2013 年 1 月 23 日
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.

サインインしてコメントする。


Matt J
Matt J 2013 年 1 月 22 日
One way
openvar xdata ydata
Then click on the cells you want to examine.
  2 件のコメント
Weijie
Weijie 2013 年 1 月 23 日
Hi I tried ur method and the variable editor pops out with only [1x51 double] [1x51 double] [1x51 double] [1x51 double] in column 1
Any other methods?
Matt J
Matt J 2013 年 1 月 23 日
If you click on those boxes they will open further to show the contents of each cell.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by