Unable to read .mat files from a folder
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Walter Roberson
el 17 de Jun. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!