From: jens on
Hey

I have the following example:
price=1:10;
fid = fopen('example.txt','wt');
fprintf(fid,'%2.0f\n',price(:));
fclose(fid);

In the above example the txt-file is saved in the current directory. How do I change where to save the txt-file? How do I save the file on the desktop?

\Jens
From: Wayne King on
"jens " <pascal(a)hotmail.com> wrote in message <hunljp$s3u$1(a)fred.mathworks.com>...
> Hey
>
> I have the following example:
> price=1:10;
> fid = fopen('example.txt','wt');
> fprintf(fid,'%2.0f\n',price(:));
> fclose(fid);
>
> In the above example the txt-file is saved in the current directory. How do I change where to save the txt-file? How do I save the file on the desktop?
>
> \Jens

Hi Jens, you just need to add the path in front of example.txt

% for windows
price=1:10;
fid = fopen('c:\data\example.txt','wt');
fprintf(fid,'%2.0f\n',price(:));
fclose(fid);

With the obvious adjustments for linux or Mac

Wayne