Create new field on struct from names on existing field
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Mikel Jimenez
il 20 Lug 2021
Commentato: Mikel Jimenez
il 20 Lug 2021
Hello,
I have a struct in Matlab as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/690288/image.jpeg)
Now, based on the "name" field, I would like to create a new field called "Color". This new field would have two values, "blue" or "red", depending on the names inside the "name" field. Specifically, if the names have he letters H1, H2 or H3, the color in the new field should be "blue", whether if the name has the letters H4, H5 or H6, it should be "red".
Anyone could help me with this?
Thanks in advance.
-Mikel
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Structures 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!