Why am I getting an 'unable to open file' error when using importdata in my batch run?
12 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Sindhu Priya
on 28 Mar 2017
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 Comments
See Also
Categories
Find more on Manage Products in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!