Message Boards Message Boards

GROUPS:

Extracting data from plot of NDSolve[ ] output

Posted 3 months ago
498 Views
|
4 Replies
|
2 Total Likes
|

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.

4 Replies
Posted 3 months 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 3 months ago

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

Posted 3 months ago
Export["output.csv", points // Prepend[{"x", "y"}]]
Posted 3 months ago

Thanks :)

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