assign cell arrays to struct
32 ビュー (過去 30 日間)
古いコメントを表示
Dear all,
is it somehow possible to assign cell arrays to the "field" and "value" variables within a struct, like test=struct(field,value) where "field" and "value" are cell arrays ?
Thanks
0 件のコメント
採用された回答
Stephen23
2022 年 5 月 28 日
You could use CELL2STRUCT :
fnm = {'hello','world'};
val = {[1,NaN],[1,4,9]};
S2 = cell2struct(val,fnm,2)
or a comma-separated list:
tmp = [fnm;val]; % the orientation is important!
S1 = struct(tmp{:})
0 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!