From: Jeff Court on
I am trying to read a folder in another directory. In this case, it is just in a subfolder of the directory I am working in.

Here is my working code. I am reading a file at every time step.
datafilename = ['TestRead' num2str(timestep) '.dat'];
soln = load (datafilename) %Load the data file based on its number


The code I thought would work...
datafilename = ['DataFiles/TestRead' num2str(timestep) '.dat'];
soln = load (datafilename) %Load the data file based on its number

Does anyone know what I am doing wrong here?
From: ImageAnalyst on
What's the error message?
You might try using fullfile() to make sure you construct the full
path of the file (starting with the drive specification), not just the
relative path.
From: Rune Allnor on
On 9 Des, 03:28, "Jeff Court" <jeff.co...(a)gmail.com> wrote:
> I am trying to read a folder in another directory.  In this case, it is just in a subfolder of the directory I am working in.  
>
> Here is my working code.  I am reading a file at every time step.
> datafilename = ['TestRead' num2str(timestep) '.dat'];
> soln = load (datafilename)                 %Load the data file based on its number
>
> The code I thought would work...
> datafilename = ['DataFiles/TestRead' num2str(timestep) '.dat'];
> soln = load (datafilename)                 %Load the data file based on its number
>
> Does anyone know what I am doing wrong here?

Assuming the directory exists and its name is
correctly spelled, it might be the wrong slash.
To do this fail-safe, use FILESEP to do something
like

pathname = 'DataFiles';
filename = 'Whatever';
datafilename = [ pathname filesep filename]

datafilename =

DataFiles\Whatever

Rune