Turn on suggestions

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

Showing results for

- JMP User Community
- :
- Discussions
- :
- Re: Simple Matrix Extraction

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

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 9, 2014 11:19 AM
(7719 views)

Quick question about extracting a single column from a large matrix into a submatrix. Just as an example below: I want extract the second column from matrix P ( I want to pull out 2,5,8) and place it into a submatrix called A. However when I try to attempt it in this way, I am getting invalid matrix token error.

P=[1 2 3, 4 5 6, 7 8 9];

for(i=1,i<=3,i = i + 1,

A = [P[i,2]];

);

Should be really simple, but for some reason it is stumping me. Thanks for the help!

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Matt's pointing you in the right direction.

Here's a more specific set of documentation on Subsetting Matrices.

The answer at the end of the book is that a subscript argument of zero selects all rows or columns.

P=**[****1** **2** **3**, **4** **5** **6**, **7** **8** **9****]**;

A=P**[****0**,**2****]**;

-Jeff

-Jeff

3 REPLIES 3

Highlighted
##

# JSL Tip: Use Matrices Instead of Lists

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Simple Matrix Extraction

see:

Xan Gregg June 15, 2009

http://www.jmp.com/support/help/Matrix_Functions.shtml

http://blogs.sas.com/content/jmp/2009/06/15/jsl-tip-use-matrices-instead-of-lists/

http://www.jmp.com/support/help/Matrix_Functions.shtmlalso:

http://www.jmp.com/support/help/Matrix_Functions.shtmlp=[1 2 3, 4 5 6, 7 8 9];

A = J(1,3);

for(i=1,i<-=3,i++

A* = P[i,2[;*

);

A

Best regards,

-Matt

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Matt's pointing you in the right direction.

Here's a more specific set of documentation on Subsetting Matrices.

The answer at the end of the book is that a subscript argument of zero selects all rows or columns.

P=**[****1** **2** **3**, **4** **5** **6**, **7** **8** **9****]**;

A=P**[****0**,**2****]**;

-Jeff

-Jeff

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Simple Matrix Extraction

Thanks guys for the quick help!