In Maple, I can get data from a plot3d like this,
restart;
Eq1:=diff(u(eta,t),t)=diff(u(eta,t),eta$2);
BCs := {u(0,t)=sin(t), u(10,t)=0};
ICs := {u(eta,0)=0};
sys:={Eq1};
pds:= pdsolve(sys,ICs union BCs,numeric,time=t,range=0..10);
p1:= pds:-plot3d(u(eta,t),t=0..35,eta=0..10,grid=[360,360]):
Here is the command for exporting data from plot p1
A:= op([1,3],p1):
a,b:= op(op([1,1],p1)):
c,d:= op(op([1,2],p1)):
m:= rhs(rtable_dims(A)[1]):
n:= rhs(rtable_dims(A)[2]):
for i from 1 to m do
for j from 1 to n do
X:= ((m-i)*a + (i-1)*b)/(m-1);
Y:= ((n-j)*c + (j-1)*d)/(n-1);
fprintf("C:/tcdata/SL1.txt",
"%f %f %f\n",Y,X,A[i,j]);
end do
end do:
close("C:/tcdata/SL1.txt"):
This gives me data in the desired format, which I can later use in another software. The format is
0.000000 0.000000 0.000000
0.097493 0.000000 0.102694
0.194986 0.000000 0.200925
0.292479 0.000000 0.294693
0.389972 0.000000 0.383998
0.487465 0.000000 0.468841
0.584958 0.000000 0.549221
0.682451 0.000000 0.625138
0.779944 0.000000 0.696593
0.877437 0.000000 0.763584
..............
How can I get data from Plot3D
in the same format (see above) in Mathematica?
ClearAll["Global`*"];
pdeset = {Derivative[1, 0][U][t, x] == Derivative[0, 2][U][t, x]}
ics = {U[0, x] == 0};
bcs = {U[t, 0] == Sin[t], U[t, 10] == 0};
bcAll = Flatten[{ics, bcs}, 1];
sol = NDSolve[{pdeset, bcAll}, {U}, {t, 0, 35}, {x, 0, 10}];
Plot3D[(U /. First@sol)[t, x], {t, 0, 35}, {x, 0, 10},
PlotRange -> All]
Plot3D
in Mathematica as I did in Maple. $\endgroup$Export["data.txt", output, "Table"];
$\endgroup$