cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Build New Matrix by Selecting Specific Columns of Another Matrix

hriek
1-Visitor

Build New Matrix by Selecting Specific Columns of Another Matrix

Please help with writing a program to do the following.

Also, if "A" matrix is n rows, "B" matrix will always be n x n.

ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald III
(To:hriek)

Here's one way ...

View solution in original post

8 REPLIES 8
StuartBruff
23-Emerald III
(To:hriek)

Here's one way ...

Thank you StuartBruff.

However the following won't work for me, but it's not like I need it anyway.

I get the error "this value must be an integer" for 'k'

MJG
18-Opal
18-Opal
(To:hriek)

Get rid of the in-line evaluation of k and it should work.

By using the in-line evaluation, you are unknowingly converting k from a range variable to an array.

hriek
1-Visitor
(To:MJG)

Thank you

StuartBruff
23-Emerald III
(To:MJG)

I see you beat me to it, Mark!

Stuart

StuartBruff
23-Emerald III
(To:hriek)

Hunter Riek wrote:

Thank you StuartBruff.

However the following won't work for me, but it's not like I need it anyway.

I get the error "this value must be an integer" for 'k'

Unfortunately, it's difficult to know why you're getting  this problem from just looking at screen shot; there are a number of little "Mathcadisms" that can make different expressions look visually similar (eg, array indices and name subscripts ... these are a common trap for novices and the forgetful!).  In addition, it may be that something else above the region of interest is affecting the results (or even a global definition that occurs after the region!).  Or even something in a region that is (partially) hidden by another region.

I'm guessing that that source of the problem is the evaluation operator (=) that you've got after the range variable k definition.  This has the side-effect of converting the range into a vector.  As you need to use integers as array indices, Mathcad is going to squawk about k being a vector.

I was intrigued with this problem to see if there was a way to accomplish the same thing without a Mathcad program.  It took me awhile, but here it is.

Matrix Extraction.PNG

AlvaroDíaz
12-Amethyst
(To:JeffH1)

Hi.

Two more ways.

Best regards.

Alvaro.

c.gif

Announcements

Top Tags