in the old old days, whos function also give total variable size, how do i do that now [ver 9.4.0.813654 (R2018a)]
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Stephen Leung
le 15 Fév 2019
Réponse apportée : Steven Lord
le 15 Fév 2019
I remember in the old old days, whos function also give total variable size, how do i do that now [ver 9.4.0.813654 (R2018a)].
I never have the need to do that till now and I am too lazy to copy and paste and sum the variable size for each variable.
I want to check the total amount of storage needed if I store the variables that were specified in whos.
Thanks
Steve Leung
4 commentaires
Réponse acceptée
Steven Lord
le 15 Fév 2019
You call whos as normal?
>> x = magic(4);
>> y = struct('foo', 1, 'bar', 2);
>> z = ["apple"; "banana"; "cherry"];
>> whos
Name Size Bytes Class Attributes
x 4x4 128 double
y 1x1 368 struct
z 3x1 258 string
Because the whos function still returns the size of the variable when called on normal workspace variables, there has to be more to your question. How exactly are you calling whos and on what type of variable are you calling it?
I want to check the total amount of storage needed if I store the variables that were specified in whos.
Note that this may get tricky if you take into account the copy-on-write behavior of MATLAB. A copy of a variable may look like it takes up the same amount of space as the original, but it may share a substantial chunk of that memory. The bytes column of the output of whos also does not account for object properties, like the properties of a graphics object.
>> [x, y, z] = peaks;
>> h = surf(x, y, z);
>> whos x y z h
Name Size Bytes Class Attributes
h 1x1 8 matlab.graphics.chart.primitive.Surface
x 49x49 19208 double
y 49x49 19208 double
z 49x49 19208 double
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Whos 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!