Message Boards Message Boards

0
|
2984 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Automatically export .dat files changing variables simultaneously?

Posted 6 years ago

Hello guys, how are you? I have the following program:

c = 0.5;

Theta = 10 Pi/15;

A[c_, Theta_] := c^2 Sin[Theta];

B[c_, Theta_] := c^3 Sin[Theta];

C[c_, Theta_] := c^4 Sin[Theta];

Mat[c_, Theta_, W_] := {{i W + A[c, Theta], 0, 0}, {0, i W + B[c, Theta], C[c, Theta]}, {A[c, Theta], 0, i W}};

DirectoryStack[]

file = OpenWrite[  " ... /example.dat", FormatType -> OutputForm]

Wmax = 2 Pi 1100 10^6; 

W = -2 Pi 1100 10^6;

dW = Pi 10^6; 

While[W <= Wmax,

f[W_] := Re[ Inverse[Mat[W]] ][[1,2]];

 Write[file, W, " ", FortranForm[ f[W]] ]; 
 \

 W += dW; 
 ]

Close[file];  

Basically, what I do is run the program for each C and Theta that I previously choose. For every value of C, I choose various other values for Theta, and every time I run the program, I need to write a different name. So, I was wondering if you could help me. I want to input an arbitrary value for C and the program automatically varies my angle Theta by 10 degrees. Also, I would like the file's name to change automatically, containing the value for C and Theta. The file must be saved in .dat, because I plot it.

Is it possible or I am being naive?

Thank you!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract