Tutorial:JMathLab/Input and Output

From HandWiki

Input/Output

Matrices and vectors can be saved into comma-separated values (CSV) files. Then one can read these objects back. Let us write a matrix into a "test.csv" file: <jc lang="math"> M=[1:3 ; 4:6 ; 7:9] printf('%f\n',M) csvwrite("test.csv",M) </jc>

You can read it back as: <jc lang="math"> M=csvread("test.csv") printf('Read matrix=%f\n',M) </jc>

Similarly, you can write and read vectors: <jc lang="math"> A=[1:10] printf('%f\n',A) csvwrite("test2.csv",A) A=csvread("test2.csv") % let us read it back printf('Read vector=%f\n',A) </jc>

Executing M-files