フィルターのクリア

How to convert cell to matrix?

1 回表示 (過去 30 日間)
sam moor
sam moor 2017 年 4 月 24 日
コメント済み: sam moor 2017 年 4 月 24 日
I have 13x1 cell. 1 to 7 rows are empty. I want to convert cell to matrix for rows 8 to 13 with different name for each cell{8,1}, {9,1}, {10,1}.....When I try cell2mat function as thetap=cell2mat(out{1,1}) it gives me error as
Cell contents reference from a non-cell array object.
Error in cell2mat (line 42) cellclass = class(c{1});
Error in Untitled3 (line 13) thetap=cell2mat(out{8,1});
Here are my code
out = cell(8,1);
for k = 8:13
myfrag = frag(:,:,k);
IM=[Int_m];
IM_frag=cat(1,IM,myfrag);
[i,j]=find(IM_frag(2:end,:)>0.1,1);
res=[IM_frag(1,j), min(IM_frag(2:3,j))];
out{k}=res;
thetap=cell2mat(out{8,1});
end
  2 件のコメント
Stephen23
Stephen23 2017 年 4 月 24 日
編集済み: Stephen23 2017 年 4 月 24 日
@sam moor: When you read the cell2mat documentation, you will learn that the input must be a cell array (as its name also implies). When you take the cell array out and use cell indexing like this out{8,1}) you are accessing whatever is inside that cell, which is clearly not a cell array itself. So you are passing something that is not a cell array to cell2mat. This will be an error. What do you expect to happen?
It seems that your usage of cell2mat is would be improved by reading the documentation, and revising how cell array indexing works:
sam moor
sam moor 2017 年 4 月 24 日
I just want to change out{8,1}, out{9,1},......to matrix in different name.

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

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by