I would like to export-to-file a list containing equations, variables, and constants, e.g.
xyz := [dx = x*y-(1/3)*(y-z), dy = -0.01*x, dz = z/10];
I have used fprintf to write to a file. The closest I got to what I want is by doing:
fd := fopen("xyz.m", WRITE) :
fprintf( fd, %s, CodeGeneration[Matlab](xyz,'output'=string) ):
Using CodeGeneration[Matlab] was the only way I found to export a list like xyz above, simply writing fprintf( fd,%s, xyz): did not work. The output is the following:
dx = x * y - y / 0.3e1 + z / 0.3e1;
dy = -0.1e-1 * x;
dz = z / 0.10e2;
This is almost what I need, except that I would like 0.10e2 to be replaced by 0.01, etc.. I played around with the CodeGeneration[Matlab] options but couldn't find a way to eliminate the e notation.
EDIT: Consider the third line. See how z/10 has become z/0.10e2 instead of, say, 0.1*z. In some cases, e0 crops up.
Any suggestions? Thanks!