Exporting .png files with the same number of digits

  • Context: Mathematica 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    files
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
member 428835
Hi PF!

I'm trying to export plots of .png files as follows:
Code:
plot[t_] := 
 Plot[0.1 Exp[-2 \[Pi] t] Cos[\[Pi]*j*x], {x, -1, 1}, 
  PlotRange -> {{-1, 1}, {-1, 1}}, Axes -> False, Background -> Black,
   PlotStyle -> Thickness[0.02]]
dt = 0.1;
Do[Export["test" <> ToString[t/dt] <> "png", plot[t], 
  ImageResolution -> 300], {t, 0, 1, dt}]

But the issue is my output images are titled test1.png, test2.png,...,test13.png...etc. How do I change the file title to read test01.png, test02.png,...,test13.png?

I really appreciate it!
 
on Phys.org
joshmccraney said:
But the issue is my output images are titled test1.png, test2.png,...,test13.png...etc. How do I change the file title to read test01.png, test02.png,...,test13.png?
I had a quick look at the Mathematica documentation and at StackExchange, and there doesn't appear to be any simple way to apply a format to the numbers. I would suggest using an If testing whether to insert a leading 0.
 
  • Like
Likes   Reactions: member 428835
DrClaude said:
I had a quick look at the Mathematica documentation and at StackExchange, and there doesn't appear to be any simple way to apply a format to the numbers. I would suggest using an If testing whether to insert a leading 0.
Okay, I wasn't sure if I missed something. Thanks!