0
$\begingroup$

enter image description here

enter image description here

Greg1[tmax_, k_, R_, J_, m_, θ0_, ω0_] :=
  NDSolveValue[
    {\!\(TraditionalForm\`\) (J + m*R)*θ''[t] == -(1/4)*k*R*θ[t],
     θ[0] == θ0, θ'[0] == ω0},
    θ, {t, 0, tmax}]
sol1 = Greg1[10, 800, 0.5, 20, 100, π/16, 0];
Plot[sol[t], {t, 0, 10},
  AxesLabel -> {"t", "θ(t)"},
  PlotStyle -> Thick,
  PlotRange -> All]

I tried to plot NDSolveValue, but it said there is no numerical value at t == 0. How can I fix it?

$\endgroup$
  • 1
    $\begingroup$ welcome. Please post code in copyable form so folks can run it to see whats going on. $\endgroup$ – george2079 Dec 2 '17 at 1:51
  • $\begingroup$ How can I post in copyable form? $\endgroup$ – Gregory Han Dec 2 '17 at 1:52
  • $\begingroup$ just copy paste from mathematica to the browser. $\endgroup$ – george2079 Dec 2 '17 at 1:54
  • $\begingroup$ Do Clear["Global`*"] and try again. You have lingering definitions. $\endgroup$ – Carl Woll Dec 2 '17 at 2:00
  • $\begingroup$ Where do I have to clear? $\endgroup$ – Gregory Han Dec 2 '17 at 2:03
1
$\begingroup$

You have the bad formatting wrapper TradionalForm in your definition of Greg1. Get rid of it by converting the cell to Raw Input Form and deleting the Null you see there. Then it will work.

Greg1[tmax_, k_, R_, J_, m_, θ0_, ω0_] := 
  NDSolveValue[
   {(J + m R) (θ^′′)[t] == -(1/4)k R θ[t], θ[0] == θ0, θ'[0] == ω0}, 
   θ, {t, 0, tmax}]
sol1 = Greg1[10, 800, 0.5, 20, 100, \[Pi]/16, 0];
Plot[sol[t], {t, 0, 10},
  AxesLabel -> {"t", "θ(t)"},
  PlotStyle -> Thick,
  PlotRange -> All]

plot

| improve this answer | |
$\endgroup$

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