CS 211 Lesson 24

Text (formatted) File Input/Output

Quote:

"The man on top of the mountain didn't fall there."  Unknown

Lesson Objectives:

Lesson:

I. MATLAB Concepts

A. Saving/Loading Workspace Variables

stores the contents of the variables Alpha and Beta to a file called mydata.mat


B. Commands vs. Functions
(unrelated to file I/O)

load
load('filename')
load('filename', 'X', 'Y', 'Z')
load('filename', '-regexp', exprlist)
load('-mat', 'filename')
load('-ascii', 'filename')
S = load(...)

function format

load filename -regexp expr1 expr2 ...

command format


C. Overview of Text I/O


D. Text Input of Tables

E. Text Input of Non-tables

Example text data file:

My test scores
78  89  93  85  94
My golf rounds
94 87
95 74
83 84

II. Good Programming Practices

III. Algorithms

 

Lab Work: Lab 24

References:  Chapman Textbook: sections 8.1, 8.6