How to create multiple structure variables and assign values to them at one line.
2 次查看(过去 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!