object properties treated as structures
Afficher commentaires plus anciens
Hi all,
I always thought that you should use get and set to play with object properties.
From time to time I stumble on a strange syntax. I did not keep track of the places where I saw that, but it definitely happened to me quite a few times. One example in this respect can be found in a recent post here on matlab central.
What I'm talking about is something like
h.XData = [1 2 3];
as opposed to
set(h,'Xdata',[1 2 3]);
Is the first syntax a real thing? I tried that, but only got the expected "Attempt to reference field of non-structure array."
I'm asking because, maybe, I could find such a syntax useful in some cases.
For instance, sometimes I need to adjust the position of an axis. Perhaps reducing its width from the default 0.7750 to 0.75. What I do is
p=get(gca,'position');
p(3) = 0.75;
set(gca,'position',p);
Perhaps, if the above syntax was real, I could go
gca.position(3)=0.75;
Anyway, is there a way to change "in place" just one of the elements of a vector attribute of some object?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Structural Mechanics dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!