Effacer les filtres
Effacer les filtres

How to export the workspace variable INFORMATION, such as Name, Value, Bytes, Class.

5 vues (au cours des 30 derniers jours)
I would like to find a way to export the description of my workspace. In the MATLAB IDE Workspace description, I find the "Bytes" field particularly informative.
I obtain something close to what I want when I type into the command line:
whos
However, I cannot properly store the output by copy-pasting it into a spreadsheet. If I could save the data listed by whos, it would be useful to search by Class, Size or Name. And doesn't need the disk space that is involved with a
save
in case of big files.

Réponse acceptée

Sean de Wolski
Sean de Wolski le 17 Oct 2017
S = whos;
T = cell2table(struct2cell(S)','VariableNames', matlab.lang.makeValidName(fieldnames(S)));
writetable(T,'whatever.xlsx')

Plus de réponses (1)

KSSV
KSSV le 17 Oct 2017
S = whos ;
S = struct2cell(S)
xlswrite('myfile.xlsx',S)
  3 commentaires
Lionel Trébuchon
Lionel Trébuchon le 17 Oct 2017
I believe that it might be because I have structs and cells in the cell itself.
One of those is not behaving well. I'll try to report on a solution if I find one.
Lionel Trébuchon
Lionel Trébuchon le 17 Oct 2017
If you only use the first 4 lines of the whos, at least you don't get any FALSE in your .xlsx.
S = whos ;
S = struct2cell(S)
S = S(1:4,:);
xlswrite('myfile.xlsx',S)
However, the " Value" information is still lost. No information is conserved about the dimensions of matrices or cells, for example.
The reason why this is disappointing is that "Value", for all its "heteroclicity", gets parsed rather well by struct2cell (which manages to extract the dimension in the form of [a,b]). It might be a feature request to xlswrite to be able to handle constructs such as "[26,3]" better.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by