1

I have a function of two variables f(v,a) and I need to export several plots of f(v) each one with different values of a.

For instance, for a=0.1,0.2,0.3...

I want a separate txt file with two columns containing $f(v)$ in the range $v=0..10$.

How can I do that?

LCarvalho
  • 9,233
  • 4
  • 40
  • 96
Rodrigo
  • 1,482
  • 9
  • 13
  • can you show what you've tried so folks no where you are stuck. Can you export one file? – george2079 Sep 29 '16 at 21:58
  • I can export one file. If I set one value of "a", I can export a single txt file with two columns, so I can set another value and export again. I want some kind of automatic process so I can set a range of values for "a" and the program exports all the txt files with their proper names. – Rodrigo Sep 29 '16 at 22:40
  • use a Do loop. – george2079 Sep 30 '16 at 00:31
  • Can you help me to do that? :) – Rodrigo Sep 30 '16 at 02:03
  • Study this carefully, look up each of the functions in the help system, try testing parts of this, all until you understand how this works and how you can use this knowledge in the future. For[a=.1, a<=.3, a+=.1, Export[StringJoin[ToString[a], ".jpg"], Plot[a x^2, {x, -1, 1}]]] You may also want to change the path where the images are sent to. Watch out for little problems when using decimal points in calculations. – Bill Sep 30 '16 at 04:27
  • You know how to export for one value, now you need to organize a loop. Instead of diving into documentation of For consider carefully reading loop alternatives... If you still need help, share code for exporting one plot. – BlacKow Sep 30 '16 at 16:36
  • @RodrigoGalvão Conseguiu uma resposta até o momento? – LCarvalho Jul 10 '17 at 19:37

1 Answers1

1
Do[
data = Table[{x, Sin[a x]}, {x, 0., 7., .1}];
Export[ToString[a] <> ".txt", data, "Table"]
, {a, 1, 3}]
Sumit
  • 15,912
  • 2
  • 31
  • 73