1
$\begingroup$

This is an old question but I am having a new problem. I was able to solve z,r,phi as a function of s but what I really need at the end is to plot z as a function of r. Since dz/dr=Tan[phi], I need to integrate Tan[phi] with respect to r. How should I do this?

With[{Bo = 5},
Eqns = {2 - Bo z[s] - Sin[φ[s]]/r[s] == 
 Derivative[1][φ][s], 
Derivative[1][z][s] == Sin[φ[s]], 
Derivative[1][r][s] == Cos[φ[s]],
z[0] == 0, φ[0] == 0, r[.001] == .001}];

sol = NDSolve[Eqns, {z, r, φ}, {s, 0.01, 3}]
f1 = (Tan[φ[s]] /. sol);
f11 = NIntegrate[f1, {r, 0, 3}];
p1 = Plot[f11, {r, 0.01, 3}, PlotStyle -> Red]

Thanks!

$\endgroup$
1
$\begingroup$

You can use ParametricPlot:

sol = NDSolveValue[Eqns, {z, r, \[CurlyPhi]}, {s, 0.01, 3}] 
ParametricPlot[ {sol[[2]][s], sol[[1]][s]} , {s, 0.01, 3},AxesLabel -> {r[s], z[s]}]

enter image description here

$\endgroup$
2
  • $\begingroup$ For some reason this does not work for me. The plot has the axes but no graph. $\endgroup$
    – Alex Wu
    Feb 9 '18 at 17:32
  • $\begingroup$ I edited my answer, hope it works now! $\endgroup$ Feb 10 '18 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.