load a file with 'dir'
2 views (last 30 days)
Show older comments
Alexandre Williot
on 17 Apr 2015
Edited: James Tursa
on 17 Apr 2015
Hello,
I want to load a file containing multiple data disorganized and I do not know why I get an error message on the load function. Someone would have an idea?
thank you
clc
clear all
close all
%--exercice2----------------------
contenu = dir('C:\Users\williot\Dropbox\UQTR 2013 - 2015\Matlab\MatLab EPK6064\Fichiers_Travail2');
for file = 1:length(contenu)
if strcmp(contenu(file).name,'.')==0 && strcmp(contenu(file).name,'..')==0
file_name = contenu(file).name;
load(file_name)
end
end
??? Error using ==> load Unable to read file Chronique_DataFRP_sujet04.mat: No such file or directory.
Error in ==> exercice2__a_williot at 12 load(file_name)
0 Comments
Accepted Answer
James Tursa
on 17 Apr 2015
Edited: James Tursa
on 17 Apr 2015
You are getting the results of dir from a different directory than the current directory. I.e., you explicitly put the path in the string argument to dir. So the file_name in question exists in that directory, but not in the current directory. You either need to use the full path name for the file to load it, or cd to that directory. E.g.,
load(['C:\Users\williot\Dropbox\UQTR 2013 - 2015\Matlab\MatLab EPK6064\Fichiers_Travail2\' file_name])
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!