Discussion:
how to use for loop variable in filename
(too old to reply)
nukeymusic
2009-12-09 16:10:55 UTC
Permalink
I have a for-loop and want to use the current value of the for-loop
variable to plot each time to a different file:

x=0:0.1:10;
for i=1:3
matfilename = sprintf('mat%d.eps', i);
plot(x,i*sin(x))
print -deps ?????????
pause
end

the idea is to get mat1.eps, mat2.eps ...

how is this done in octave?

thanx
Francesco Potortì
2009-12-10 15:41:29 UTC
Permalink
Post by nukeymusic
I have a for-loop and want to use the current value of the for-loop
x=0:0.1:10;
for i=1:3
matfilename = sprintf('mat%d.eps', i);
plot(x,i*sin(x))
print -deps ?????????
pause
end
the idea is to get mat1.eps, mat2.eps ...
Try
print(matfilename)
nukeymusic
2009-12-11 09:38:20 UTC
Permalink
Post by Francesco Potortì
Post by nukeymusic
I have a for-loop and want to use the current value of the for-loop
x=0:0.1:10;
for i=1:3
matfilename = sprintf('mat%d.eps', i);
plot(x,i*sin(x))
print -deps ?????????
pause
end
the idea is to get mat1.eps, mat2.eps ...
Try
print(matfilename)
print(matfilename, '-deps') works, thanks!

Continue reading on narkive:
Loading...