% ECE 1250 S12 Lecture M13 % Today's lecture covers MatlabĀ® commands for reading and writing to and from memory. % There are several different ways of storing information in files. % Native Data Files. Save things compactly in binary. %----------------------------------------------------- save % Saves everything in file matlab.mat (binary) % Matlab format (undecipherable) but is cross platform compatible a = [0 3] save('a') % Just saves variable 'a' save('filea','a') % Saves in file called filea.mat % Strange things... save('b','a') % Creates file b.mat instead of saving b b = [9, 4] save('b','a') % Saves vars b and a in file matlab.mat load % loads everything load('filea','a') % 1st arg must be filename for load % Check whether a particular file exists. exist('matlab.mat','file') % Need 2nd arg = 'file' % See what's in a file whos('-file','matlab.mat') % Unix style, -file 1st arg % General purpose wizard for reading in data uiimport % Data Import and Export in text files. %----------------------------------------------------- big_array = rand(3,4) % Store data with commas between items. dlmwrite('myfile.txt',big_array,',') % write as text file, new_big_array = dlmread('myfile.txt',',') % read with slightly different syntax % Read a .wav file using wavread() function %----------------------------------------------------- % Low-level file I/O example functions in rd_str_file.m and wr_str_file.m