필터 지우기
필터 지우기

load a file with 'dir'

조회 수: 2 (최근 30일)
Alexandre Williot
Alexandre Williot 2015년 4월 17일
편집: James Tursa 2015년 4월 17일
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)

채택된 답변

James Tursa
James Tursa 2015년 4월 17일
편집: James Tursa 2015년 4월 17일
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])
  댓글 수: 1
Alexandre Williot
Alexandre Williot 2015년 4월 17일
of course! thank you very much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by