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
- :
- Discussions
- :
- How to evaluate a matrix on the fly?

Topic Options

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

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

Mar 20, 2013 7:10 AM
(1303 views)

I am sure there is a simple answer to this problem but I can't figure it out. I am trying to compute distance between two objects using a distance matrix. I can't get the following JSL code to work:

dt = Open (dist matrix.jmp);

m = dt << Get All Columns As Matrix();

dt2 = Open(students.jmp);

col = Column("Prefect No");

B=col<<Getasmatrix;

n=nrow(dt2);

a=j(n,1,0);

for(i=1,i<=n, i++, a*=m[b ,4]);*

show(a);

I keep getting an error when evaluating m[,]. I tried Eval and other things but it doesn work.

Can anyone help?

3 REPLIES

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

Mar 22, 2013 9:31 AM
(1140 views)

I figured out what the main error was. Some of the rows had missing values and when JMP tried to evaluate the missing subscript it bombed. So I used the following code:

for**(**i=**1**,i<=n, i++, if**((**not**(**is missing**(**A**[**i**])))**, C**[**i**]**=m**[**A**[**i**]**,**8]**, C**[**i**]**=**.))**;

It works fine.

Now my only issue is that when I use

m = dt << Get All Columns As Matrix();

The subsequent matrix m is not in the order that I have it in the dataset. So trying to figure out how to keep the original order. Any ideas?

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

Mar 22, 2013 1:47 PM
(1140 views)

Got an example data set? I had one and tried the following code, and it had the correct order. It replaced character values with '1's though, which is along the lines of what I'd expect.

dt = current data table();

m = dt << Get All Columns As Matrix();

show(m);

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

Mar 24, 2013 6:21 PM
(1140 views)

I saved my dataset back to excel and brought it back into JMP. Now that dataset when is made into a matrix is in the correct order. I must have reset the default order of the columns when I recreated it in JMP. So now everything works. Thanks for the help.