General Tips

When dealing with multimedia in MATLAB it is always a good idea to end every command with a semicolon. Use

[data, sample_rate, bits_per_sample] = wavread('c:\path\to\file\filename.wav');

instead of

[data, sample_rate, bits_per_sample] = wavread('c:\path\to\file\filename.wav')

A semicolon keeps MATLAB from echoing the output of a command to the console window. Use a semicolon if you do not want to wait for 10s worth of data sampled at 44100 samples per second scroll by your screen.


Start every MATLAB program with the commands clear and clc.

# clear memory
clear

# clear console
clc


Useful Commands

Functions for interacting with wav files

	#Read a wav file:
	 [data, sample_rate, bits_per_sample] = wavread('c:\path\to\file\filename.wav');
	#Play the data from a wav file:
	 wavplay(data, sample_rate);
	 sound(data, sample_rate);
	#Save a wav file:
	 wavwrite(data,sample_rate,bits_per_sample,'/path/to/file/filename.wav');


Reverse the data in a vector

# Reverse a row vector
row_vector = fliplr(row_vector);

# Reverse a column vector
col_vector = flipud(col_vector);

NOTE: The vector returned by wavread is a column vector. flipud must be used to reverse it.


Convert a row vector to a column vector and vice versa

#Convert a column vector to row vector.
row_vector = rot90(col_vector);

#Convert a row vector to a column vector.
col_vector = rot90(row_vector);

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood