Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Mar 24, 2013
05:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 24, 2013
05:48 PM

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.

Solved! Go to Solution.

ACCEPTED SOLUTION

Accepted Solutions

Mar 24, 2013
06:41 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 24, 2013
06:41 PM

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

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

5 REPLIES 5

Mar 24, 2013
06:41 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 24, 2013
06:41 PM

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

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

Mar 25, 2013
02:43 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 25, 2013
02:43 PM

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.

Mar 25, 2013
04:40 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 25, 2013
04:40 PM

Its important to keep range variables and vectors apart!

See if the attached helps.

Mar 26, 2013
06:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 26, 2013
06:01 AM

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

Mar 26, 2013
06:18 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 26, 2013
06:18 AM

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!