Loading multiple *mat files
2 views (last 30 days)
Show older comments
Elizabeth Drybrugh
on 31 Jan 2018
Commented: Stephen23
on 31 Jan 2018
all_data =[];
files = dir('*.mat');
for q = 1:lenght(files)
load(files(q).name);
all_data = [all_data D.F];
end
This is my code now but get an error load(files(q).name); saying error in read files... New to matlab so apologise in advance for silly mistakes.
0 Comments
Accepted Answer
Stephen23
on 31 Jan 2018
Edited: Stephen23
on 31 Jan 2018
For a basic explanation see the MATLAB documentation:
If all of the .mat files contain the same variables then try something like this:
files = dir('*.mat');
out = load(files(1).name);
for k = 2:numel(files)
out(k) = load(files(k).name);
end
[out.F]
1 Comment
Stephen23
on 31 Jan 2018
@Elizabeth Dryburgh: please show the complete error message. This means all of the red text.
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!