How to create multiple structure variables and assign values to them at one line.
4 ビュー (過去 30 日間)
古いコメントを表示
I want to create a structure type for example 'AC' and assign values to its fields all at one line as follows:
[AC.a, AC.b] = [5, 15]
0 件のコメント
回答 (2 件)
Dyuman Joshi
2023 年 3 月 16 日
編集済み: Dyuman Joshi
2023 年 3 月 16 日
%Assign any type of data to a field
[AC.a, AC.b, AC.c, AC.d] = deal(5, 15, {'cell'}, '0');
AC
0 件のコメント
Voss
2023 年 3 月 16 日
One way:
[AC.a, AC.b] = deal(5, 15);
AC
Another way:
C = {5, 15};
[AC.a, AC.b] = C{:};
AC
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!