how can i put value of cell in vector?
1 回表示 (過去 30 日間)
古いコメントを表示
this error appear during the run of my program
"Cell contents reference from a non-cell array object."cell
U=[ ]
S={1 ,2 ,3}
for i=1:numel(S)
U=[U S{i}];
end
U = unique(U,'first');
0 件のコメント
採用された回答
Star Strider
2019 年 11 月 8 日
Two options that come quickly to mind:
S={1 ,2 ,3};
U = [S{:}]
U = cell2mat(S)
Obviously these only work if the cell contents can be appropriately concatenated. If they cannot be, it is best to leave the cell array as a cell array, and address its contents as needed.
2 件のコメント
Star Strider
2019 年 11 月 8 日
The code you posted runs without error in R2019b, as does the code I posted.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!