Hi all,
This is probably a simple command, but I cannot figure it out. I am using the following to spit out some results from a system of ODEs, but I can't figure out how to label the individual columns t, H, W R, etc. Any suggestions?
Thanks!
> file := "/Desktop/Aquifer results2/comp60.txt"; try fd := fopen(file, 'WRITE', 'TEXT'); for tt from 0 to 945 do fprintf(fd, "%a %a %a %a %a %a\n", (eval([t, H(t), Weq, Req, price, total], sol2a(tt)))[]) end do finally close(file) end try;
%;
>
possibility
Here's one approach,
proc() local dsys, data, w; dsys := {diff(v(t),t) = -x(t), diff(x(t),t)=v(t), x(0)=1, v(0)=0}; data := dsolve(dsys, 'numeric', 'output'=Array([seq(0..2, 0.1)])); w := 15; printf("%*s\n", w, map(convert, data[1,1], string)); printf("%*f\n", w, data[2,1]); end proc(): t v(t) x(t) 0.000000 0.000000 1.000000 0.100000 -0.099833 0.995004 0.200000 -0.198669 0.980067 0.300000 -0.295520 0.955336 0.400000 -0.389418 0.921061 0.500000 -0.479426 0.877583 0.600000 -0.564643 0.825336 0.700000 -0.644218 0.764842 0.800000 -0.717356 0.696707 0.900000 -0.783327 0.621610 1.000000 -0.841471 0.540302 1.100000 -0.891207 0.453596 1.200000 -0.932039 0.362358 1.300000 -0.963558 0.267499 1.400000 -0.985450 0.169967 1.500000 -0.997495 0.070737 1.600000 -0.999574 -0.029200 1.700000 -0.991665 -0.128844 1.800000 -0.973848 -0.227202 1.900000 -0.946300 -0.323290 2.000000 -0.909298 -0.416147As a bous, with Maple13 you can use convert~(data[1,1], string) to convert the elements in the Vector stored in data[1,1] to a string. A slightly more interesting method is to assign an inline operator for convert and then use it with the ~ operator:
printf
It is also possible to write the printf commands as
printf("%{}15a\n%15f",data[1,1],data[2]); t v(t) x(t) 0.000000 0.000000 1.000000 0.100000 -0.099833 0.995004Alec
nice
Thanks. I was pretty sure there was a way to "map" %a over an rtable, but didn't think of using an empty printf_rtable modifier. Nifty. That is
printf("%{}a\n", some_rtable)is roughly equivalent to
printf("%s\n", map(convert, some_rtable, string));There really should be a
There really should be a predefined and simple procedure for that in Maple for example
MatrixPrint( Column1, Column2, Column3, labels=["A", "AA", "AAA"]
The current Maple command :
for i to 10 do printf("\t%d\t%2d\t%3d\t%4d\t%5d\t%6d\ \n", i^1, i^2, i^3, i^4, i^5, i^6) end do;
In my opinion is too complicated ///*&..;;££%%%>>\\££"" what langauge is that ?! Greek ?
using Matrix to present table of results
I achieve this result using Maple's Matrix data structure, as follows:
interface( rtablesize=30 ): dsys := {diff(v(t),t) = -x(t), diff(x(t),t)=v(t), x(0)=1, v(0)=0}; data := dsolve(dsys, 'numeric', 'output'=Array([seq(0..2, 0.1)])); evalf[6]( < data[1,1], data[2,1] > );All this does is create a matrix from the two elements returned by dsolve. Note that it's necessary to increase the setting of rtablesize if the matrix has more than 10 rows or columns; here, 30 is more than enough.
If only there was a way to copy this result into MaplePrimes.
Doug
Thanks
Thanks for this discussion.