Get Help

Turn on suggestions

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

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Need to select the maximum of two column matrices ...

Options

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

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

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2017
10:52 AM

02-23-2017
10:52 AM

Hello,

I run into the situation frequently where I need to select the lesser of greater of two equations. Suppose I have equation A and equation B. I've input say 6 values for A and B in a single column matrix and evaluated each. I would like to define variable C as the maximum of A or B output for each row. I attached a worksheet that demonstrates my problem.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2017
12:03 PM

02-23-2017
12:03 PM

Generally you would use the vectorize operator (see operators item in the tab, then under Vector and Matrix) for this job, but unfortunately, because max() and min() functions accept more than 2 arguments vectorization does not work for them.

So you have to write a small program:

Success!

Luc

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2017
12:03 PM

02-23-2017
12:03 PM

Generally you would use the vectorize operator (see operators item in the tab, then under Vector and Matrix) for this job, but unfortunately, because max() and min() functions accept more than 2 arguments vectorization does not work for them.

So you have to write a small program:

Success!

Luc

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2017
01:20 PM

02-23-2017
01:20 PM

Re: Need to select the maximum of two column matrices and return as a column matrix.

Thnaks Luc. That looks like that will accomplish my goal. I'm not familiar with Mathcad programming so I'll have to study up on that. At first pass I can't get the program lined up as yours is so it isn't evaluating.

Also, after m original post I found a related thread which someone helped solve using the vectorize operator and I have made that one work.

Comparing data from two arrays

Is there a benefit of one method over the other?

Thanks again for the help.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2017
04:13 PM

02-23-2017
04:13 PM

Re: Need to select the maximum of two column matrices and return as a column matrix.

Ah, yeah, completely forgot about this trick. Essentially what Werner shows is how to obtain a max function limited to 2 arguments, such that vectorization can work.

Yes Brandon, there is an advantage: Vectorization is usually faster.

Success!

Luc

Top Tags