Creating a function that gives the size and name of the variables in the mat-file
2 ビュー (過去 30 日間)
古いコメントを表示
Hi, I am trying to write a function that gives the size and name of the variables in the mat-file
I have this:
S = whos('-file','workspace313.mat')
% lists in alphabetical order the names, sizes, and types of all variables in the currently active workspace.
for k = 1:length(S)
disp([S(k).name, mat2str(S(k).size)]
How do I go on?
0 件のコメント
回答 (1 件)
Image Analyst
2021 年 5 月 9 日
Try this:
d = dir('*.mat'); % Get a list of all .mat files in the current folder.
for k = 1 : length(d)
s = load(d(k).name) % Load it.
names = sort(fieldnames(s)); % Get fieldnames and sort them.
for k2 = 1 : length(names)
fprintf(' File "%s" has a field called %s.\n', d(k).name, names{k2});
end
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT-Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!