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
- :
- I need to extract one row of a matrix

Options

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

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

Showing results for

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

08-31-2016
07:57 AM

08-31-2016
07:57 AM

I need to extract one row of a matrix

Hello,

I have a matrix of steel shapes and the corresponding section properties.

Currently for each section property I am using a vlookup function. This requires I type in the shape of the beam inside each command every time. There has to be a way to combine a vlookup and extract an entire row based on that lookup item. I assume I could then put the extracted items into a single column matrix and have each passed into the variables. This would allow me to only type the shape into a single lookup function. I'm new to Mathcad so I'm probably overlooking the obvious, but I have searched for a solution and can't find one. Anyone know of a way to do what I am trying to do?

.

13 REPLIES 13

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

08-31-2016
11:36 AM

08-31-2016
11:36 AM

Re: I need to extract one row of a matrix

Use "match" to obtain the row index for specified shape. Then, use the matrix row function to extract it.

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

08-31-2016
12:00 PM

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

08-31-2016
12:00 PM

08-31-2016
12:00 PM

Re: I need to extract one row of a matrix

Something like this:

Here's one way to then extract each of the individual variables with their units:

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

08-31-2016
12:51 PM

08-31-2016
12:51 PM

Re: I need to extract one row of a matrix

Mark Gase wrote:

Something like this:

This is the kind of situation where I'd almost certainly write a function to simplify things and make the worksheet easier to read (and, hopefully, debug / maintain).

In Prime, you'd replace the clumsy transpose/column-operator with just a row-operator (Mathcad 15 has no row operator and I don't have Prime available).

(In this instance, as there is only likely to be one AISC table, it would probably be OK to write the function such that it picks up AISC from the worksheet rather than passing it as a parameter. The advantage of doing this is that it potentially makes the function less confusing to the reader. In reality, I'd probably still define it as getLabel(AISC, label))

Stuart

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

08-26-2017
02:55 AM

08-26-2017
02:55 AM

Re: I need to extract one row of a matrix

This is an elegant solution for applyign units.

One thing I found out, you can create local functions within functions, see below, pretty powerful

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

08-26-2017
05:13 AM

08-26-2017
05:13 AM

Re: I need to extract one row of a matrix

Guess you posted in the wrong thread!?

Did you mean this one https://community.ptc.com/t5/PTC-Mathcad-Questions/Incongruence-in-matrix-units/td-p/482098

EDIT: Ah, no! I just realize that your post refers to a former post by MJG.

One problem:

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

08-29-2017
11:59 PM

08-29-2017
11:59 PM

Re: I need to extract one row of a matrix

What is the issue? I don't want to apply units if the value is not intended to have a dimension. What if the value is NaN, a string or a complex number? How did you end up with units of m? Did you add those manual in the result ?

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

08-30-2017
09:15 AM

08-30-2017
09:15 AM

Re: I need to extract one row of a matrix

No, I didn't add anything manualy.

You can give it a try yourself, but be sure to use the value 0 where i had done so.

Explanation for this behaviour can be found in the thread Io referred to.

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

08-31-2017
12:29 AM

08-31-2017
12:29 AM

Re: I need to extract one row of a matrix

Aha - that is interesting, thank you for the tip!

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

08-31-2016
12:06 PM

08-31-2016
12:06 PM

Re: I need to extract one row of a matrix

Thank you all for the help. I'll see what I can put together with this info.

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

08-31-2016
12:37 PM

08-31-2016
12:37 PM

Re: I need to extract one row of a matrix

1) You could define a variable for your shape like

shape:="W44X335"

and later use this variable in your vlookup commands.

A.g:=vlookup(shape,AISC,4)[1*in

2) As Mark already wrote you can use match to get the row number, like

rownr:=match("W44X335", AISC)[1[1

or to just search in the first column

rownr:=match("W44X335", AISC^<1>)[1

Then you could Primes row selector to assign a variable the full row of data.

You may even multiply this row (you would have to use the vectorization operator!) with a row vector consisting of the appropriate units for each column and assign the result to a row vector consisting of the Mathcad variable names like A.g, f, etc. and you have your single variables with just one command.

The attached may be helpful:

EDIT: Haven't seen Marks last reply before posting my own. I would prefer his "ApplyUnits" over my "multiply" 😉

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

08-23-2017
05:30 PM

08-23-2017
05:30 PM

Re: I need to extract one row of a matrix

Hi,

I have a similar case. I have an extensive table with 5 columns (0 to 4) and more than 1000 rows!

I want to select the values for the first 4 variables (each variable in one of the first 4 columns) and find the row that contains the exact values I selected so to find the value of the 5th column (4) at that row.

Any ideas? Thanks!

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

08-24-2017
12:45 AM

08-24-2017
12:45 AM

Re: I need to extract one row of a matrix

Use match function to find index of row and column of the steel function shape label, then use the mathcad function to extract a row based on the idea of row returned form match function