lecturenotes10_22 - 10/21/2008 Input/OutputusingFiles...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
10/21/2008 1 Input/Output using Files October 15, 2008 10/21/2008 1 Reading and Writing to files Matlab provides many mechanisms for reading from and writing to files: load textread fopen, fclose, fid fread fi t fwrite 10/21/2008 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10/21/2008 2 LOAD Early in the term we used the LOAD command. LOAD can be used to: load a saved workspace, or load data from a .dat file into the workspace Using load to load data, creates a variable array containing all the data. Data must all be of the same type 10/21/2008 3 textread The textread function reads ASCII files that are formatted into columns of data, where each column may be of a different type Each column is stored as a separate output array VERY useful for incorporating tables of data textread is probably the most useful command for reading files when using Matlab for data analysis 10/21/2008 4
Background image of page 2
10/21/2008 3 textread (cont’d) Syntax: [a,b,c,. .]=textread(filename, format, n) filename is the name of the file to open format is a string containing a listing of the type of data in each column format contains the same type of descriptors as the fprintf command n is the number of lines to read 10/21/2008 5 textread (cont’d) Suppose the our wind speed data also contained dates, times and directions: 010107 0000 15 SW 010107 0010 10 S 10/21/2008 6 | We could read this into Matlab using the following command:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

lecturenotes10_22 - 10/21/2008 Input/OutputusingFiles...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online