cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Extracting Individual Values from Odesolve

astevenson-2
1-Visitor

Extracting Individual Values from Odesolve

I apologize if this has been asked before as it would seem something others would have asked but my search of the blog returned nothing. In the attached file I have a simple 2nd order linear DE. I can see to extract individual values from the Odesolve output. I've also figured out how to extract the response to a vector. My question is how to know I've captured all the important content from the Odesolve output with my selected time increment of .01s. What if I was looking for the exact maximum. Seems like with my approach I'm only getting an approximation of the Odesolve output.

ACCEPTED SOLUTION

Accepted Solutions

Odesolve by default uses 1000 intervals so it should return 1001 pairs of values. The number of intervals can be changed by using an additional argument of odesolve.

But the output of an odesolveblock is a function which automatically interpolates between those values. Thats the reason you can use the derivative to find relative extremas as Luc had shown.

Of course you can reconstruct the vectors as you had done (see attached file) but you could have a look at the standalone ODE solvers which return the raw vector.

To find the local max and min values, you may use the functions localmax and localmin.

Of course the best results are achieved by the exact symbolic solution which unfortunately is not always that easy to find.

LT

View solution in original post

5 REPLIES 5
LucMeekes
23-Emerald III
(To:astevenson-2)

If you want the exact location of the maximum, there's no better way than the symbolic way. See attached.

{Altough I wonder why I get a single solution for the extreme....}

But if you insist on wanting to do it numerically you could try inserting, just below the first plot:

To find the subsequent (local) extremes, just move the "t:=" guess value near the next location, like:

Etcetera.

Success!

Luc

Odesolve by default uses 1000 intervals so it should return 1001 pairs of values. The number of intervals can be changed by using an additional argument of odesolve.

But the output of an odesolveblock is a function which automatically interpolates between those values. Thats the reason you can use the derivative to find relative extremas as Luc had shown.

Of course you can reconstruct the vectors as you had done (see attached file) but you could have a look at the standalone ODE solvers which return the raw vector.

To find the local max and min values, you may use the functions localmax and localmin.

Of course the best results are achieved by the exact symbolic solution which unfortunately is not always that easy to find.

LT

Thanks Luc and Leopold. What is an example of a standalone ODE solver?

You probably know that you can change the numeric algorithm used by odesolve by rightclicking at "odesolve" . Default is Adams/BDF, a hybrid solver..

There are a couple of standalone solvers with completetly different syntax - one for each algorithm.

E.g. AdamsBDF() as the hybrid solver and additionally four solvers for stiff systems (BDF,Radau,Stiffb,Stiffr) and four for non-stiff systems (Adams, rkfixed,Rkadapt,Bulstoer) Lookup the help and quicksheets for more information.

LT

.

Thanks Leopold. Didn't know you could do that with Odesolve. Yes I knew vaguely about the stiff and non-stiff solvers as I've been using them on my sample problems before I deploy them on a real live problem at work.

Announcements

Top Tags