Home > Archive > Matlab > January 2008 > dlmwrite([path file],....) does not work on Mac OS?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
dlmwrite([path file],....) does not work on Mac OS?
|
|
| Michael Ršoesch 2008-01-31, 8:28 pm |
| The following code should create a subdirectory in the current working
directory and write a file into that directory:
A = ones(10);
path = strcat(pwd,'\dlmtest');
name = 'dlmA';
mkdir(path)
dlmwrite([path name],A,'\t');
Obviously this works on Windows platforms, but on my Mac platform, the
subdirectory is created but no file is written.
Are there some Mac-users who could confirm this?
Thanks, Michael
| |
| Walter Roberson 2008-01-31, 8:28 pm |
| In article <fnt1pn$k0$1@news.albasani.net>,
=?UTF-8?B?TWljaGFlbCBSwppvZXNjaA==?= <mr_78-25@web.de> wrote:
>The following code should create a subdirectory in the current working
>directory and write a file into that directory:
>A = ones(10);
>path = strcat(pwd,'\dlmtest');
>name = 'dlmA';
>mkdir(path)
>dlmwrite([path name],A,'\t');
>Obviously this works on Windows platforms, but on my Mac platform, the
>subdirectory is created but no file is written.
>Are there some Mac-users who could confirm this?
No need to test it to see the problem.
On the Mac or any Unix system, that is going to create take
the current directory name, add the literal \dlmtest\ on to it,
and create a directory with that name. For example if the
current directory was /usr/people/roberson then the created
directory would be /usr/people/roberson\dlmtest\
which is a directory named roberson\dlmtest\ in the /usr/people
directory.
You then add 'dlmA' to the end of that and try to create
the file with that name. In this example, it would come
out as a file named /usr/people/roberson\dlmtest\dlmA
which is a file named roberson\dlmtest\dlmA in the directory
/usr/people
The base problem is that '' is not the directory seperator for
unix systems. You may wish to recode using '/' in both cases:
on windows systems, Matlab will recognize '/' as a directory
seperator. But even better would be to use fullfile()
instead of coding the directory seperator explicitly.
--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec
| |
| Michael Ršoesch 2008-01-31, 8:28 pm |
| Thanks for this good explanation.
Michael
| |
| Steven Lord 2008-01-31, 8:28 pm |
|
"Michael Ršoesch" <mr_78-25@web.de> wrote in message
news:fnt1pn$k0$1@news.albasani.net...
> The following code should create a subdirectory in the current working
> directory and write a file into that directory:
>
> A = ones(10);
> path = strcat(pwd,'\dlmtest');
I don't know if this is related to the behavior you're seeing, but rather
than explicitly specifying a path separator like you do here, I'd use
FULLFILE and FILESEP or PATHSEP to generate the directory name. I'd also
avoid using the name "path", as that's one of the main functions for
manipulating the MATLAB path. Does FILESEP return '' or '/' on your Mac?
mypath = fullfile(pwd, 'dlmtest');
*snip*
--
Steve Lord
slord@mathworks.com
| |
| Michael Ršoesch 2008-01-31, 8:28 pm |
| I just got a hint from someone else:
You have just to change backslash to slash for unix-based systems and it
works:
path = strcat(pwd,'/dlmtest/');
Michael
Michael Ršoesch schrieb:
> The following code should create a subdirectory in the current working
> directory and write a file into that directory:
>
> A = ones(10);
> path = strcat(pwd,'\dlmtest');
> name = 'dlmA';
> mkdir(path)
> dlmwrite([path name],A,'\t');
>
> Obviously this works on Windows platforms, but on my Mac platform, the
> subdirectory is created but no file is written.
>
> Are there some Mac-users who could confirm this?
>
> Thanks, Michael
| |
| Michael Ršoesch 2008-01-31, 8:28 pm |
| Thanks for your hints.
Michael
|
|
|
|
|