|
On Jul 5, 1:14 pm, "Juliette Salexa" <juliette.physic...@gmail.com>
wrote:
> I am having problems with fopen.
>
> filename=test.m
> fopen(filename,'r')
>
> works fine, but:
>
> fopen(fullfile('directory1','directory2',filename,'r')) OR
> fopen('directory1','directory2',filename,'r') OR
> fopen(/directory1/directory2/filename,'r'))
>
> do NOT. (the latter command works in UNIX but not windows).
>
> So how do I open a file that's not in my working directory ??
When you say that this worked in Unix:
fopen(/directory1/directory2/filename,'r'))
I think you're telling porkies.
For a start, it ends with )), which is bad syntax.
Secondly, there are no quotes around the string.
Furthermore, you need to attach a handle.
This might work in Unix (if the names are correct):
fid=fopen('/directory1/directory2/filename','r');
Now, the reason this does not work in Windows has nothing to do with
Matlab.
It's the way you define the file in windows.
It needs to be:
fid=fopen('../directory1/directory2/filename','r');
or
fid=fopen('c:/directory1/directory2/filename','r');
or, even better:
fid=fopen('c:\directory1\directory2\filename','r');
|