How to create multiple structure variables and assign values to them at one line.
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Dyuman Joshi
il 16 Mar 2023
Modificato: Dyuman Joshi
il 16 Mar 2023
%Assign any type of data to a field
[AC.a, AC.b, AC.c, AC.d] = deal(5, 15, {'cell'}, '0');
AC
0 Commenti
Voss
il 16 Mar 2023
One way:
[AC.a, AC.b] = deal(5, 15);
AC
Another way:
C = {5, 15};
[AC.a, AC.b] = C{:};
AC
0 Commenti
Vedere anche
Categorie
Scopri di più su String Parsing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!