2
$\begingroup$

I can't spot the error, can someone help me?

NumericalGenSol = 
   NDSolve[
    {g/l* Sin[θ[t]] + (γ* θ'[t])/m + θ''[t] == f/(m l), θ[0] == α Degree, θ'[0] == β Degree},
    θ[t], {t, 0, 10}];

AnalyticalGenSol is just alike NumericalGenSol just without Sin but only with $\theta$ and I used DSolve instead.

Manipulate[{NumericalGenSol, AnalyticalGenSol}, θ[t], {t, 0, 10}];
Plot[
 {Evaluate[θ[t] /. NumericalGenSol], θ[t] /. AnalyticalGenSol}], 
 {t, 0, 10}, {α, 0, 90}, {β, 0, 90}
]

Any idea how I can combine in one manipulate plot?

$\endgroup$
4
  • 1
    $\begingroup$ In your first codeline NumericalGenSol = ... there are several undefined parameters. That's why NDSolve doesn't evaluate! $\endgroup$ Feb 28, 2019 at 18:12
  • $\begingroup$ Sorry they are defined in the top? the error message is: Manipulate::vsform: Manipulate argument [Theta][t] does not have the correct form for a variable specification. $\endgroup$ Feb 28, 2019 at 18:17
  • 1
    $\begingroup$ Where to find the "top"? NDSolve only works for numerical problems. $\endgroup$ Feb 28, 2019 at 18:20
  • 3
    $\begingroup$ Ulrich means that you should include in your post all definitions necessary to run your code, otherwise we cannot run it on our machine and tinker with it to try and provide a solution to your problem. $\endgroup$
    – MarcoB
    Feb 28, 2019 at 18:27

1 Answer 1

3
$\begingroup$

If you define all the parameters and remove the excesses, the code can be like this

g = 9.8; l = 1; m = 1; f = 1; γ = .1;
sol = 
 ParametricNDSolveValue[
   {g/l*Sin[θ[t]] + (γ*θ'[t])/m + θ''[t] ==f/(m l), 
    θ[0] == α , θ'[0] == β}, θ[t], {t, 0, 10}, {α, β}];

Manipulate[
  Plot[
    {sol[α, β], 
     Evaluate[θ[t] /. 
       DSolve[
         {g/l*θ[t] + (γ*θ'[t])/m + θ''[t] == f/(m l), 
          θ[0] == α, θ'[0] == β}, 
         θ, {t, 0, 10}]]}, 
    {t, 0, 10}], 
  {α, 0, Pi/2},
  {β, 0, Pi/2}]

fig1

$\endgroup$

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.