1
$\begingroup$

Given a DSolve example:

sol = Flatten[
DSolve[{D[x[t, th], {t, 2}] == -0.2*D[x[t, th], t]/2.30, 
 Derivative[1, 0][x][0, th] == 10.8*Cos[th], x[0, th] == 0}, 
x[t, th], t]]

Then assigning sol to a function:

 x[t,th]/.sol[[1]]

I'm having trouble plotting a 2D portion of it:

Plot[x[t,1],{t,0,20}]

And also trouble Manipulating it:

Manipulate[x[t,th], {th, 0, Pi/2}]

What mistakes am I making?

$\endgroup$
0

1 Answer 1

5
$\begingroup$

I'm not sure what you think x[t,th]/.sol[[1]] does. From your question, Here is what I think you're trying to accomplish.

sol = Flatten[  DSolve[{D[x[t, th], {t, 2}] == -0.2*D[x[t, th], t]/2.30, 
    Derivative[1, 0][x][0, th] == 10.8*Cos[th], x[0, th] == 0}, 
   x[t, th], t]];

x[t_, th_] = sol[[1, 2]]; (* This defines the function using the solution from DSolve *)

To get the Plot do the following:

Plot[x[t, 1], {t, 0, 20}] 

To Manipulate, do the following:

Manipulate[Plot[x[t, th], {t, 0, 100}, PlotRange -> {{0, 100}, {0, 130}}], {th, 0, Pi/2}]

Hope this helps.

$\endgroup$
3
  • $\begingroup$ Thanks @RunnyKine. I'm taking a look now. $\endgroup$
    – xaxXos
    Commented Feb 4, 2013 at 16:14
  • $\begingroup$ I edited your code so that the manipulate shows how the function transforms (added a constant range: PlotRange -> {{0, 100}, {0, 130}}. I hope you don't mind. $\endgroup$
    – gpap
    Commented Mar 13, 2013 at 15:27
  • $\begingroup$ @gpap. Thanks for the edit. Looks good. $\endgroup$
    – RunnyKine
    Commented Mar 13, 2013 at 15:55

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.