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$

closed as off-topic by m_goldberg, Chris K, xzczd, Henrik Schumacher, LCarvalho Dec 3 '17 at 17:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Chris K, xzczd, Henrik Schumacher, LCarvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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

$\endgroup$

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