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

min/max of odesolve solution

MilchMachtMunte
2-Guest

min/max of odesolve solution

Hi

I tried to find the max value of a solution from odesolve.

As argument I used a vector. It works fine for the direct solution of odesolve. But if I try to use a function on the solution (derivate with respect to time) I get stucked.

You have to scroll down a little bit and you will find the explained problem.

Thanks in advance for helping me out.

ACCEPTED SOLUTION

Accepted Solutions

1) in "max(derv(vh,i))" there is missing the closing parenthesis

2) your function "derv" uses indices i-1 and i+1. Therefore you can only apply indices from 1 to pkt-1 and not, as you do, from 0 to pkt. Thats the reason for the error regarding the array index you get everytime you call derv(). The two invalid indices being 0-1 and pkt+1.

3) Even if you correct the above you would be disappointed. You feed a range variable in derv(...) and so max(..) aould be applied to every element singly so you would get pkt times the max of a single constant.

You have to create a vector to get max to work

odemax1.png

Edited: Changed file, added another method to get the derivative to get the maximum with better accuracy.

View solution in original post

5 REPLIES 5

1) in "max(derv(vh,i))" there is missing the closing parenthesis

2) your function "derv" uses indices i-1 and i+1. Therefore you can only apply indices from 1 to pkt-1 and not, as you do, from 0 to pkt. Thats the reason for the error regarding the array index you get everytime you call derv(). The two invalid indices being 0-1 and pkt+1.

3) Even if you correct the above you would be disappointed. You feed a range variable in derv(...) and so max(..) aould be applied to every element singly so you would get pkt times the max of a single constant.

You have to create a vector to get max to work

odemax1.png

Edited: Changed file, added another method to get the derivative to get the maximum with better accuracy.

Thanks a lot. I got it right now. Perfect explanations!


As I changed some things I got other troubles.
For example with the mathcad derivative. If I don't use the bold self-written formula, it does not calculate to the end. I marked the questions green. Feel free to comment.

Its important to keep range variables and vectors apart!

See if the attached helps.

wow, perfect. Thank you so much for the explications!
absolutely stunned about people's help here. You helped me a lot.

edit: I hope one day I have the capabilities to help others too

Leander Rankwiler wrote:

wow, perfect. Thank you so much for the explications!
absolutely stunned about people's help here. You helped me a lot.

edit: I hope one day I have the capabilities to help others too

Thats neighbourly help in our case 😉

Greetings to Switzerland!

Announcements

Top Tags