function whoss(big) % whoss( bigFlag ) % Stephen's version of "whos" that is nicer, i.e. give sizes in % KB and MB when appropriate. % If given any non-false argument for bigFlag, will only display variables % that take up more than 1 MB of RAM % % e.g. % whoss 1 % only displays variables > 1 MB in size if nargin < 1, big = false; end % The only tricky part: need to call the "whos" command in a % different workspace, so use "evalin" command: s=evalin('base','whos'); N = length(s); % loop over all variables in the workspace: for n = 1:N nm = s(n).name; sz = s(n).bytes; if sz < 1024 if ~big, fprintf('\t%-20s\t%.0f\n',nm,sz); end elseif sz/1024 < 1024 if ~big, fprintf('\t%-20s\t%.1f Kb\n',nm,sz/1024); end else fprintf('\t%-20s\t%.1f Mb\n',nm,sz/1024/1024) end end