Why am I getting an 'unable to open file' error when using importdata in my batch run?

14 visualizaciones (últimos 30 días)
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

Respuestas (1)

Sindhu Priya
Sindhu Priya el 28 de Mzo. de 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.

Categorías

Más información sobre Manage Products en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by