How do I create a "shared field" in a structure array?
Mostrar comentarios más antiguos
I want to create a field that all structures have access to. I want it this way so that by updating the value in one field the field in the other stuctures automatically adjust so that I do not have to set those individually.
Ex)
Ant(1).age=343;
Ant(1).sharedField=3;
>>Ant(2).age
Ant(2).age=
278
>>Ant(2).sharedField
Ant(2).sharedField=
3
Respuestas (2)
Walter Roberson
el 16 de Dic. de 2012
0 votos
You will need to use Object Oriented Programming to create a new class that is something like a structure array.
Image Analyst
el 16 de Dic. de 2012
0 votos
I'm not sure but I think it could be done if you have a class variable and then have one of the properties access a global variable. Then every instance of that class variable would essentially be referencing the same global variable so changing it on one should change it for all others if you write the properties correctly. See " classdef" in the help for further info.
Categorías
Más información sobre Whos en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!