Message Boards Message Boards

Extracting data from plot of NDSolve[ ] output

Posted 3 years ago

Hello, I am solving two coupled differential equations using the NDSolve given below:

Clear["Global`*"];
a = 0.1; k = 0.01; \[Mu]e = 0.001; \[Mu] = 0.001; B = 3.16228; \
\[Sigma]0 = 4*10^-2; \[Phi] = 10; q = 3000; kf = 0.6; U = 0.75549;
s = NDSolve[{{\[Mu]e/\[Mu] (u''[r] + 1/r u'[r]) - \[Mu]/
       k u[r] - (\[Sigma]0 B^2 u[r])/\[Mu] == -1/\[Mu] \[Phi], 
    T''[r] + 1/r T'[r] == -u[r]/U (2 q)/(a kf)}, u[a] == T[a] == 0, 
   u'[$MachineEpsilon] == 0, T'[$MachineEpsilon] == 10}, {u, 
   T}, {r, $MachineEpsilon, a}]
Plot[Evaluate[{u[r]} /. s], {r, $MachineEpsilon, a}]

I am getting this plot for velocity

enter image description here

I want to get all the point on the curve only to extract. Please help.

POSTED BY: KRISHAN SHARMA
4 Replies
Posted 3 years ago

Hi Krishan,

One way to do it

plot = Plot[Evaluate[{u[r]} /. s], {r, $MachineEpsilon, a}];
points = Cases[plot, Line[{x__}] :> x, All]

Show[plot, ListPlot[points, PlotStyle -> Red]]

enter image description here

POSTED BY: Rohit Namjoshi
Posted 3 years ago

Thanks Rohit...can I get these points into an Excel file?

POSTED BY: KRISHAN SHARMA
Posted 3 years ago
Export["output.csv", points // Prepend[{"x", "y"}]]
POSTED BY: Rohit Namjoshi
Posted 3 years ago

Thanks :)

POSTED BY: KRISHAN SHARMA
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