Why am I getting an 'unable to open file' error when using importdata in my batch run?
조회 수: 13 (최근 30일)
이전 댓글 표시
Hello,
I have been working with a script that imports data from an *.inp file, runs several calculations with that data, then writes the results to an output file. I've worked with this code extensively in the GUI on my computer with no problems, but now I'm trying to submit it as a batch job on a different computer. Now I am running into an error when trying to import my data, however, and I was not having this issue before. I am running from the correct directory, all the files I need are transferred to the correct location, and I've added all necessary filepaths, including the location of my data, so I don't know why it is unable to import the data now. The code looks something like this:
input = 'filepath\data.inp';
d = importdata(input,',',9);
The exact error I get is
{Error using importdata (line 136)
Unable to open file.
Error in myscript (line 21)
d = importdata(input,',',9);
Error in run (line 96)
evalin('caller', [script ';']);
}
Any idea what may be causing this or how to fix it?
Thanks
댓글 수: 0
답변 (1개)
Sindhu Priya
2017년 3월 28일
Hi Shania,
One of the potential reasons causing the issue might be the file path. So, try replacing the line
input = 'filepath\data.inp';
with
input=fullfile('filepath','data.inp');
And you can try wrapping the code in a try catch block, as you can confirm whether the referred file is in the expected path or not.
The following link has an example which can be useful to resolve the issue
Regards,
Sindhu.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Manage Products에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!