You are a guest. Restricted access. Read more

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:


M=[1:3 ; 4:6 ; 7:9]
printf('%f\n',M)
csvwrite("test.csv",M)

You can read it back as:


M=csvread("test.csv")
printf('Read matrix=%f\n',M)

Similarly, you can write and read vectors:


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)

Use these I/O methods in a stand-alone application, since for security reasons execution of these examples is disabled.

Executing M-files

You can execute M-file (Matlab files with the extension “m”) using the method loadfile(“scrip.m”)

jmathlab/io.txt · Last modified: 2013/04/14 16:52 (external edit)
Back to top
CC Attribution-Share Alike 3.0 Unported
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0