load a file with 'dir'
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alexandre Williot
am 17 Apr. 2015
Bearbeitet: James Tursa
am 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 Kommentare
Akzeptierte Antwort
James Tursa
am 17 Apr. 2015
Bearbeitet: James Tursa
am 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])
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!