From: hpc on
Hi All,

Searching for a solution to variable file name. I use the code

for i = 0 : 100
var1=['check.0000',num2str(i),'.pfb'];
end

I want the var1 to hold
check.00000.pfb
check.00001.pfb
......
check.00010.pfb
......
check.00100.pfb


but this program will give

check.00000.pfb
check.00001.pfb
......
check.000010.pfb % i want check.00010.pfb
......
in every next loop value but the problem is that I will have to create
if condition i.e. i<10 i<100 and so on...
is there any other way to do it.

Thanking in advance
Ashutosh Singh
From: us on
hpc <ashutoshsingh.ashu(a)gmail.com> wrote in message <2f1a029f-37c6-4585-a26d-2f1f34540973(a)z17g2000vbd.googlegroups.com>...
> Hi All,
>
> Searching for a solution to variable file name. I use the code
>
> for i = 0 : 100
> var1=['check.0000',num2str(i),'.pfb'];
> end
>
> I want the var1 to hold
> check.00000.pfb
> check.00001.pfb
> .....
> check.00010.pfb
> .....
> check.00100.pfb
>
>
> but this program will give
>
> check.00000.pfb
> check.00001.pfb
> .....
> check.000010.pfb % i want check.00010.pfb
> .....
> in every next loop value but the problem is that I will have to create
> if condition i.e. i<10 i<100 and so on...
> is there any other way to do it.
>
> Thanking in advance
> Ashutosh Singh

one of the solutions

n=3;
clear s; % <- save old stuff(!)...
for i=1:n
fn=sprintf('f%3.3d',i);
s.(fn).f=1;
end
disp(s)
%{
f001: [1x1 struct]
f002: [1x1 struct]
f003: [1x1 struct]
%}

us
From: hpc on
absolutely fine !!!!!
it works !!!!!
thanks a lot ....
ashu