how to create used input struct names
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Happy PhD
le 29 Avr 2020
Réponse apportée : Geoff Hayes
le 29 Avr 2020
Hi. I created a struct,
data = struct()
I would like to add fields to it based on user input from app designer.
For example user writes a number '125' as input, then I want to create field called 'laserDist123mm' and add it to data struct.
data.laserDist123mm = 199;
equal to something.
is there any way to do this?
I want to add the new fields dynamically...
0 commentaires
Réponse acceptée
Geoff Hayes
le 29 Avr 2020
data = setfield(data, 'laserDist123mm', 199)
or as you have shown
data.laserDist123mm = 199;
which will add the field dynamically to the structure.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!