Effacer les filtres
Effacer les filtres

How can assign value to a field of structure?

1 vue (au cours des 30 derniers jours)
SM
SM le 8 Juil 2021
Réponse apportée : Matt J le 8 Juil 2021
I have a structure A of size (A,1)=10. I want to assign value 1 to one of the fields of A from 1 to 5. The output will be:
A(1).B=1
A(2).B=1
A(3).B=1
A(4).B=1
A(5).B=1
B is one of the fields of A.
I can do it by using loop. Is it possible to avoid loop?

Réponses (1)

Matt J
Matt J le 8 Juil 2021
[A(1:5).B]=deal(1)

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by