Cell contents reference from a non-cell array object.

why this error appear "Cell contents reference from a non-cell array object"
U = {} at first
U = TI(s).Si;
TI is strict and Si is a field of TI of cell class
sitem = unique([U{:}]);

9 件のコメント

Adam Danz
Adam Danz 2019 年 12 月 17 日
U = {};
sitem = unique([U{:}]);
That should not produce an error. The source of the error must be something else or the example isn't accurately reflecting your variables.
Geoff Hayes
Geoff Hayes 2019 年 12 月 17 日
Mira - U is initialized as a cell array, but then you re-initialize this to whatever Si is
U = TI(s).Si;
Perhaps you mean to do
U{1} = TI(s).Si;
Adam Danz
Adam Danz 2019 年 12 月 17 日
Good eye. I missed that.
Mira le
Mira le 2019 年 12 月 17 日
I mean U = TI(1).Si I replace s by 1
ans Si ={} is a field of struct TI
for example TI(1).Si= {2 3}
Adam Danz
Adam Danz 2019 年 12 月 17 日
The problem is to the left of the equal sign, not the right. See Geoff's comment again.
Mira le
Mira le 2019 年 12 月 17 日
U = TI(s).Si;
it depend on the cells in TI(s).Si
Adam Danz
Adam Danz 2019 年 12 月 17 日
If TI(s).Si isn't a cell, then U won't be a cell, even if you initialize it as a cell
U = {};
U = TI(s).Si; % you're just overwriting U here
If you use Geoff's suggestions, U will remain as cell.
U = {};
U{1} = TI(s).Si;
Mira le
Mira le 2019 年 12 月 18 日
but Si is cell, how it won't be cell
Adam Danz
Adam Danz 2019 年 12 月 18 日
I don't know what your code does. I saw your comment, "for example TI(1).Si= {2 3}" which indicates that Si is a cell array but is that always true? Maybe it is; I don't know.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Identification についてさらに検索

製品

リリース

R2017a

タグ

質問済み:

2019 年 12 月 17 日

コメント済み:

2019 年 12 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by