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

Build New Matrix by Selecting Specific Columns of Another Matrix

SOLVED
Highlighted
Newbie

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

Here's one way ...

View solution in original post

8 REPLIES 8

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

Here's one way ...

View solution in original post

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

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'

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

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.

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

Thank you

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

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.

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

I see you beat me to it, Mark!

Stuart

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

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

Re: Build New Matrix by Selecting Specific Columns of Another Matrix

Hi.

Two more ways.

Best regards.

Alvaro.

c.gif