Unable to read .mat files from a folder
1 view (last 30 days)
Show older comments
I have multiple .mat files in the a folder. I want to read each of the files and compare its data with one of the file of the same folder.
In line 6 I expected the path of the .mat file to be displayed. What was expected is C:\Users\Toshiba\Desktop\friday work\1_1_1.mat, C:\Users\Toshiba\Desktop\friday work\1_1_2 and so on for each file, instead i got C:\Users\Toshiba\Desktop\friday work\. , C:\Users\Toshiba\Desktop\friday work\..
The code I used is:
f_s = 'C:\Users\Toshiba\Desktop\friday work\';
f_s_2 = 'C:\Users\Toshiba\Desktop\friday work\1_1_2.mat';
ss = dir(f_s);
for i = 1:1:size(ss, 1)
im_nm = strcat(f_s, ss(i).name);
disp(im_nm);
end
I am unable to read the .mat file in the folder
0 Comments
Accepted Answer
Walter Roberson
on 17 Jun 2012
Use
im_nm = fullfile(f_s, ss(i).name)
and keep in mind that when you dir() on a folder, you get everything in the folder, including all the directory links such as "." and ".." . To eliminate those
ss = dir(f_s);
ss([ss.isdir]) = [];
0 Comments
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!