1
$\begingroup$

I want to substitute the solution of a differential equation into a function, and plot the function. My code is as attached:

teta=NDSolveValue[{θ''[t] == (m l (g -i (θ'[t])^2 Cos[θ[t]]) (Sin[θ[t]] - μk Cos[θ[t]]))/(i +m l^2 Sin[θ[t]](Sin[θ[t]] - μk Cos[θ[t]]))
, θ[0] == π/2, θ'[0] == 0} /. {m -> 0.03517,l -> 0.0279,g -> 9.81,i -> 10.^-3 ,μk -> 0.1827}, θ , {t, 0, 5}]

F[t] =={ m l (θ''[t] Cos[θ[t]] - θ[t]'^2 Sin[θ[t]])} /. θ[t] -> teta//Simplify

 

The code works until here. When I try to plot F[t], mathematica only displays the axes but not the graph itself. Please send help. Thank you.

$\endgroup$
4
  • $\begingroup$ In F[t], l, m and (\[Theta]^\[Prime]\[Prime])[t] are undefined. Also, F[t] = ... not F[t] == .... $\endgroup$ Commented Nov 12, 2020 at 2:05
  • $\begingroup$ If i use F[t]= instead, would I be able to plot the graph? $\endgroup$ Commented Nov 12, 2020 at 2:10
  • 1
    $\begingroup$ Also need to define l, m, and θ''[t] in the definition of F. $\endgroup$ Commented Nov 12, 2020 at 2:16
  • $\begingroup$ Why do I have to define θ''[t]? $\endgroup$ Commented Nov 12, 2020 at 2:32

1 Answer 1

3
$\begingroup$
Clear["Global`*"]

teta = NDSolve[{θ''[t] == (m l (g - 
            i (θ'[t])^2 Cos[θ[t]]) (Sin[θ[t]] - μk Cos[θ[t]]))/(i + 
          m l^2 Sin[θ[t]] (Sin[θ[t]] - μk Cos[θ[t]])), θ[0] == π/
        2, θ'[0] == 0} /. {m -> 0.03517, l -> 0.0279, 
      g -> 9.81, i -> 10^-3, μk -> 0.1827}, θ, {t, 0, 5}][[1]];

F[t_] := m l (θ''[t] Cos[θ[t]] - θ'[t]^2 Sin[θ[
         t]]) /. {m -> 0.03517, l -> 0.0279} /. teta

Plot[F[t], {t, 0, 5}]

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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