DSPRelated.com
Forums

saving a file

Started by jplav32 July 16, 2004
Hi,

I am actually using matlab to generate random data files and I'd
like to know if there is any way to force matlab to save my files
with a different name each time I run the program. Actually, I use

fopen('data.txt','wb')

to save my random data but I'd like this name to change automaticly
each time I run the program... for example : data.txt, data1.txt,
data2.txt and so on ...

Do you have any idea how to do this?

Thanks a lot,

Jean-Philippe



Try something like this:

for index = 1:nfiles
fopen(['data' int2str(index) '.txt'],'wb')
end

--- jplav32 <> wrote:
> Hi,
>
> I am actually using matlab to generate random data
> files and I'd
> like to know if there is any way to force matlab to
> save my files
> with a different name each time I run the program.
> Actually, I use
>
> fopen('data.txt','wb')
>
> to save my random data but I'd like this name to
> change automaticly
> each time I run the program... for example :
> data.txt, data1.txt,
> data2.txt and so on ...
>
> Do you have any idea how to do this?
>
> Thanks a lot,
>
> Jean-Philippe >

=====
Juan I. Arvelo, Jr., Ph.D.
Johns Hopkins University
11100 Johns Hopkins Rd.
Laurel, MD 20723
240.228.4293
__________________________________


Jean-Philippe-

Something like this shuuld work.

for i = 1 : 10
file_name = ['data' num2str(i) '.txt']
fopen(file_name,'wb')
end

Hope this helps
Tarang

On Fri, 16 Jul 2004 jplav32 wrote :
>Hi,
>I am actually using matlab to generate random data files and I'd
>like to know if there is any way to force matlab to save my files
>with a different name each time I run the program.  Actually, I use
>fopen('data.txt','wb')
>to save my random data but I'd like this name to change automaticly
>each time I run the program... for example : data.txt, data1.txt,
>data2.txt and so on ...
>Do you have any idea how to do this?
>Thanks a lot,
>Jean-Philippe
>_____________________________________
>Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.
>_____________________________________
>About this discussion group:
>To Join:  m...@yahoogroups.com
>To Post:  m...@yahoogroups.com
>To Leave: m...@yahoogroups.com
>Archives:
>http://www.yahoogroups.com/group/matlab
>More DSP-Related Groups:
>http://www.dsprelated.com/groups.php3
>
>Yahoo! Groups Links
>To BR> >.
>

Tarang Dadia
Graduate Student
Wireless Networking Lab
University of Texas at Arlington.