read data from variables with names matching patterns
古いコメントを表示
A student of mine saved a .mat file containing variables named x1, x2, ..., x50, y1, y2, etc. How can I write program that will open the .mat file, and loop through each of these pairs of data. Somehow it involves "who" but I'm not seeing how to make it work.
2 件のコメント
Roy Goodman
2014 年 6 月 20 日
dpb
2014 年 6 月 20 日
The better answer is to teach the student "don't do that" --
回答 (1 件)
Jos (10584)
2014 年 6 月 20 日
X = load('StudentsMatfile.mat') ;
LABELS = fieldnames(X) ;
N = numel(LABELS)
DATA = cell(N,1)
for k=1:N
DATA{k} = X.(LABELS{k}) ;
end
save ('SupervisorMatfile.mat', 'DATA','LABELS') ;
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!