SHAZAM Community
Ask Your Question
0

From data-file to matrix

asked 2016-10-28 13:04:16 +0000

TL gravatar image

Hi all,

Shazam is a flexible tool. I want to use Shazam in my input-output analysis. The input-output coefficients are stored in a text-file, dimension 50x50. Question: How can I “transform” data-files to matrices so I can solve the system by using matrix algebra?

Regards, TL

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2016-10-28 13:33:27 +0000

Use the READ command to read directly from the file but specify the dimensions using ROWS= and COLS= values. (see page 34 of the v11 manual) where is says:

ROWS=, COLS=

Specifies the number of ROWS and COLumnS when a matrix is being read in. Only one matrix can be read in on a given READ command and if a matrix is being read in, no other variables may be read in on that READ command. SKIPIF commands are not in effect when a matrix is read. The beginning observation on the SAMPLE command is used as the first row number for the matrix. Use the option BEG=1 to ensure that the matrix begins at row 1.

eg. To read 50x50 matrix from file data.txt to matrix X

READ(mydata.txt) X / ROWS=50 COLS=50

Note also that the MATRIX command will read variables in memory too. e.g. to stack variables as matrix columns you might do:

MATRIX example = var1|var2|var3

So for you could also create a new Dataset on the DATA menu of the correct dimensions, paste in the values to the data grid and use the 'Rename Multiple Variables' feature to create names for the columns, then add it to your Workspace. The dataset will automatically be read if Automatic READ is enabled on it and then the MATRIX command could be used. This would be a much more convoluted method than the simple READ command.

edit flag offensive delete link more

Comments

Thanks to the ShazamHelp. Your suggestion solved the problem, and the follow up tip is great :-)

TL

TL gravatar imageTL ( 2016-10-28 13:53:12 +0000 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2016-10-28 13:04:16 +0000

Seen: 1,898 times

Last updated: Oct 28 '16