14.03.2014 Views

Scripting Guide - JMP

Scripting Guide - JMP

Scripting Guide - JMP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

20 Introducing JSL Chapter 1<br />

Samples of JSL Scripts<br />

matrix multiplication and division, determinants, eigenvalue decomposition, and so on. Thus you can<br />

now perform custom calculations of your own.<br />

For example, JSL has a straightforward notation for entering matrices:<br />

L=[1 2 3, 4 5 6, 7 8 9, 10 11 12];<br />

M=[0 1 2, 2 1 0, 0 1 1, 2 0 0];<br />

N=[1 2 3 4, 4 3 2 1, 0 1 0 1];<br />

O=[0 1 2, 2 1 0, 1 2 0];<br />

Simple operations look like this:<br />

R = L+M; // matrix addition<br />

[ 1 3 5,<br />

6 6 6,<br />

7 9 10,<br />

12 11 12]<br />

Q=L*M`; // matrix multiplication of L by M-transpose<br />

[ 8 4 5 2,<br />

17 13 11 8,<br />

26 22 17 14,<br />

35 31 23 20]<br />

You can even solve a linear system, that is, find the vector x for the square, nonsingular matrix A and<br />

vector b you specify such that x = A – 1 b :<br />

A=[1 -4 2, 3 3 2, 0 4 -1];<br />

b=[1, 2, 1];<br />

x=solve(A,b);<br />

[-17,5,19]<br />

For numerical work needing matrix factors, <strong>JMP</strong> offers operations such Cholesky, eigenvalue, and<br />

singular-value decomposition:<br />

E=[ 5 4 1 1, 4 5 1 1, 1 1 4 2, 1 1 2 4];<br />

L=cholesky(E);<br />

[ 2.2360679774998 0 0 0,<br />

1.7888543819998 1.3416407864999 0 0,<br />

0.4472135955 0.1490711985 1.9436506316151 0,<br />

0.4472135955 0.1490711985 0.91465912076 1.7149858514251]<br />

You can read the numeric columns of a data table into a matrix to perform custom calculations:<br />

my matrix = current data table()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!