Matlab:Evaluating ODE at Points

  • MATLAB
  • Thread starter qspeechc
  • Start date
  • #1
840
14
Hello everyone.

I have a second order ODE, which I reduced to two first order ODEs, and solved with ode45. Now I want to evaluate the solution and the derivative at certain points (specifically, I want to plot the Poincare section).

So, what I did is this:

Code:
>> sol=ode45(@...);
>> xint=a:b;    
>> [Sxint, Spxint]=deval(sol, xint);
>> A=[Sxint, Spxint];
>> plot(Sxint, Spxint,'o')

Where:
xint is the points at which I want to evaluate the solution.
Sxint is the value of the solution at the points xint.
Spxint is the value of the derivative at those points.

But this is clearly wrong. I know the solution should be periodic, but I get something random. I think it's the plotting I'm doing incorrectly. Any help appreciated.
 

Answers and Replies

  • #2
840
14
Ok, instead, I created a seperate M-file:

Code:
hold on,
for i=1:length(xint)
    plot(Sxint(:,i), Spxint(:,1),'.')
end

Is this correct?
 
  • #3
840
14
Nevermind, I've figured it out, you can close the thread.
 

Related Threads on Matlab:Evaluating ODE at Points

  • Last Post
Replies
5
Views
5K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
3
Views
4K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
2
Views
8K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
0
Views
3K
Top