Reference .mat variable name after loading
显示 更早的评论
I am trying to perform operations on a number of .mat files in a loop. The problem is that some of the loaded files do not come in with the variable name "maxtees". For example, some will be named "maxtees2000". Thus, I can not perform function that references "maxtees" (e.g., rows(maxtees)) when this isn't the appropriate variable name. Is there a way I can pull or reference these variables without having to re-save them all or set up different loops for different naming conventions? Thanks.
files = dir(['max*' '*.mat'])
maxT = [];
for i = 1:length(files)
load(files(i,1).name)
maxtees = maxtees(find(all(maxtees,2)),:);
maxtees = [gridNos maxtees(:,4) maxtees(:,5) maxtees(:,6) maxtees(:,9) maxtees(:,10)];
maxT = [maxT;maxtees];
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!