import an easy file
조회 수: 5(최근 30일)
I know it is a easy question, but I should be extremely grateful if someone give me and answer. I have a string with a complete path. How do I Import this textfile? I know it is stupid, but i shoud thank you 1000 times if you cam help me. I get the message unable to import file.
Elias Gule 2018년 3월 29일
In this code:
[FileName,PathName] = uigetfile('../*.csv','MultiSelect','off','title','path');
FileName is simply the name of the file you selected. So if the file is not located in the present working directory, fopen will not be able to read it. So it will return an fid of -1, which is an invalid file 'pointer'.
What you need is to supply the full path of the file to fopen. So doing this:
fid = fopen(fullfile(PathName,FileName));
will return a valid file 'pointer'.