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

** Community Tip** - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements.
X

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

Aug 15, 2020
06:52 AM

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

Aug 15, 2020
06:52 AM

A problem of vectors and functions, please help

Hello ptc community

I have tried to find the maximum value of a function evaluated in a defined range, however the max or min function can only be applied to vectors. I would like to know if there is a function or some way that allows me to obtain the maximum value of a function. I try to vectorize the results as attached in the example, however this is limited to functions lacking units as far as I could see. I would appreciate any help

This is the function that I have been working on, it is only referential but with this I wanted to imply that I prefer to use units during the calculation. (for more details see the attached sheet)

here I show how it is possible to vectorize a function already evaluated in a defined range

but the above is not possible if units are used

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Aug 15, 2020
09:07 AM

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

Aug 15, 2020
09:07 AM

You cannot use a range with a unit assigned as an index to a vector. (Ranges are for plotting and indexing!) But you can create a vector that mimics the same range with your units:

9 REPLIES 9

Aug 15, 2020
07:25 AM

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

Aug 15, 2020
07:25 AM

May by so

Aug 15, 2020
07:59 AM

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

Aug 15, 2020
07:59 AM

well it seems that it was something simple xD, thanks

But since we are here, I would like to know that it takes into account the maximize function, although the first requirement argument is the function, the second argument is a value that remains to be defined by the user that will give me a local maximum of the evaluated function. In the case of evaluating M_k with a parameter between 0 and 10, it gives me a value of 3 that corresponds to the maximum value of the function between that range, but if I wanted the second value that corresponds to 4.

Now if I assign a value between 11 and 20 as a parameter, it should give me 21, which corresponds to the maximum value, however, sometimes it gives me 19.5, sometimes 19. Why is this? Although this is a problem of maximums and minimums in a function, I am not allowed to apply derivatives since the function is generated from conditionals.

Aug 15, 2020
09:23 AM

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

Aug 15, 2020
11:06 AM

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

Aug 15, 2020
11:06 AM

thanks for your answer, It seems to me a good alternative way to evaluate the maximum values, but I would like to know why the values of the maximize function varied and did not coincide in an answer

it tells me that a conditional expression cannot be evaluated 😞

Aug 15, 2020
09:07 AM

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

Aug 15, 2020
09:07 AM

Aug 15, 2020
10:48 AM

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

Aug 15, 2020
10:48 AM

Yes, that was my mistake, I was using a range with a unit assigned as the index of a vector, which is meaningless, I didn't understand how this type of vectorization worked. I already understood it, thank you very much. Now I only have the doubt of why the maximize function gave those results.

Aug 15, 2020
12:11 PM

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

Aug 15, 2020
12:11 PM

Looks like you found a bug in Prime 5 which is already fixed in Prime 6:

Aug 15, 2020
05:29 PM

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

Aug 15, 2020
05:29 PM

Here is another (clumsy and sure not satisfactory) workaround for this Prime bug using the built-in "localmax" function:

Aug 15, 2020
06:43 PM

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

Aug 15, 2020
06:43 PM

Thanks for your answer, it is true there are some errors that the new version has fixed, I was also testing and now it allows me to vectorize the function with a small program evaluating the function in a certain domain and grouping the answers in a vector, this I could not do it in the older version.

Regarding the solution that you propose for maximums and minimums, the localmax function does not seem awkward to me, it is the one required to find not only a maximum point of a range. Thank you