WriteDataOutExp.mw
This Maple file is called WriteDataOutExp and is used to calculate the analytical solution for an example problem and to write the results to a text file (maple_output.txt).
| > |
 |
Specify the values for x at which the analytical solution will be calculated and later exported. Make sure
you have the whole range (i.e., 0 to 1) of x included.
| > |
![`:=`(xdata, matrix(11, 1, [seq(`*`(k, `*`(`/`(10.0))), k = 0 .. 10)])); 1](images/WriteDataOutExp_2.gif) |
 |
(1) |
Input the Governing Equation and Boundary Conditions:
| > |
 |
 |
(2) |
| > |
 |
 |
(3) |
Solve the differential equation and rearrange the results to the desired form:
| > |
 |
 |
(4) |
| > |
 |
 |
(5) |
| > |
 |
 |
(6) |
| > |
 |
 |
(7) |
Make sure the solution satisfies the boundary conditions:
| > |
 |
 |
(8) |
| > |
 |
 |
(9) |
Plot the results:
| > |
 |
| > |
 |
Save the analytical solution at the x values specified at the beginning of this worksheet as uana[i].
| > |
![for i to rowdim(xdata) do `:=`(uana[i], evalf(subs(x = xdata[i, 1], u))) end do; 1](images/WriteDataOutExp_23.gif) |
Export the Analytical Solution from Maple into theText File:
| > |
![`:=`(uanalytical, evalm(matrix(rowdim(xdata), 2, [seq([xdata[kd, 1], uana[kd]], kd = 1 .. rowdim(xdata))]))); 1](images/WriteDataOutExp_35.gif) |
 |
(11) |
Note: To export to a text file, the formats compatible with Maple are Arrays, Matrices, etc. For additional help please type ? writedata;
| > |
 |
Now, the output from the analytical solution is stored into a file called "maple_output.txt" in the folder where you saved this original Maple file.