Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks @RunnyKine. I'm taking a look now. –  xaxXos Feb 4 '13 at 16:14
    
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. –  gpap Mar 13 '13 at 15:27
    
@gpap. Thanks for the edit. Looks good. –  RunnyKine Mar 13 '13 at 15:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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