ENG1060 Lecture 4: Week 4 Save, Import & Export

42 views2 pages
**for%workspaces%and%variables.
Workspace
save <filename>.mat
load <filename>.mat
Importing
fopen, fclose, fgetl functions
1.
importdata function
2.
fopen, fclose, fgetl functions
filename = <filename>
file_id = fopen('filename')
A%file%is%assigned%a%file%identifier%once%opened
**file%must%be%in%current%directory
fgetl >>>%get%data%from%file
<data/var name> = fgetl(file_id)
Imports%data%as%string.
**can%only%get%one0line0of0data with%each%separate%call.
fclose >>>%closes%a%file
fclose(file_id)
importdata function
all_data = importdata('filename')
all_data.data(:,1) -for columns
Loads%all%data%in%file,%no%need%for%fopen%and%fclose
+%More%control
-Can't%write%to%files%AKA%can't%edit%files
Imports%data%as%structure (data,%text%data%and%column%headers)
Accessed%via:%content = <matrix>.<content_type>
Separate data%into%variables%after%importing%it
Exporting
fprint%+%fopen
If%'w'%doesn't%work,%use%'wt'.
Week$4:$Save,$Import$&$Export
Saturday,%12%August%2017
21:18
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents