help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read/Write files with a variable name..


From: c.
Subject: Re: Read/Write files with a variable name..
Date: Fri, 30 Sep 2011 03:40:14 +0200

On 30 Sep 2011, at 03:19, Minkyung Kersti Son wrote:

> I just want to
> 
> read/open file names including
> 
> 001, 002, ...,288 (for i=1:288)
> 
> and save/write file names including
> 
> 001,002,...,288 (for i=1:288).
> 
> fid=fopen('true.'???)
> 
> ... T_T

you can include a number in a filename using "sprintf" 

for ii = 1:128

 input_file_name  = sprintf ("input_file_%3.3d.dat", ii);
 output_file_name = sprintf ("output_file_%3.3d.dat", ii);
 fid_in  = fopen (input_file_name, "r");
 fid_out = fopen (input_file_name, "w");

 %% do stuff

 fclose (fid_in);
 fclose (fid_out);

endfor

for more info type "help sprintf" or "doc sprintf" at the octave prompt.
c.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]