# Result from NDSolve will not plot [closed]  Greg1[tmax_, k_, R_, J_, m_, θ0_, ω0_] :=
NDSolveValue[
{\!$$TraditionalForm\$$ (J + m*R)*θ''[t] == -(1/4)*k*R*θ[t],
θ == θ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?

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

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},
θ, {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] 