how to load multiple files from directory into an array using matlab?
显示 更早的评论
i have a directory that includes some .mat files , i want to load all these files into an array .
i tried something like this :;
x1=load('C:\Users\me\OneDrive\Desktop\project\a\first_file.mat')
x2=load('C:\Users\me\OneDrive\Desktop\project\a\second_file.mat')
... and so on for all the files in the directory , and at the end i want to have an array such that:
arr(1)=x1 ...
how can i access the directory and load all of the files at the same time into an array ?
ps: i tried using path before and dir but then i got this error :
> error using eval , undefind function 'workspacefun' for input
> arguments of type struct
thank you in advance.
5 个评论
Walter Roberson
2022-8-9
Is there exactly one variable in the .mat file, and it has the same name in each case?
Is it a numeric row vector? Numeric column vector? 2D? 3D?
molan
2022-8-9
Walter Roberson
2022-8-9
Are the variable names the same inside the file? Is there exactly one variable in the file?
Does it matter which order the entries go into the overall matrix?
Are there any .mat files in the directory other than the ones to be processed ?
molan
2022-8-10
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!