UW EE 299 - Frequently used Matlab Commands

Unformatted text preview:

Frequently used Matlab commands For loop : for variable = start : stepsize : end some Matlab statements end Example: for n=1:10 z=z+n; end If/then : If (expression that is either true or false) some Matlab statements else some Matlab statements end You can also use “elseif” to have more conditions to test. Sounds: [mysound, fs] = wavread( ‘filename.wav’ ) Convert a sound file into a Matlab vector Output variables: • mysound : vector for sound vector storage • fs : sampling frequency sound(mysound, fs) Playback the sound vector Input variables: • mysound: input sound vector • fs : sampling frequency of mysound wavwrite(mysound, Fs, ‘output name’ ) Convert the sound vector into a wave file Input variables: • mysound: input sound vector • fs : sampling frequency of mysound • ‘output name’ : name of output file (any name you like)Images: A = imread(filename,fmt) Convert figure file into image matrix in Matlab Input variables: • Filename.fmt : input figure Output variables: • A: image matrix in Matlab figure Creating a new blank figure for showing an image colormap(map) sets the colormap to the matrix map imagesc(C) displays matrix C , scale data and display as image imshow(A) displays the load figure matrix A Example: x=imread('lighthouse.jpg'); figure imshow(x)Plotting: plot(y) Make a linear plot of matrix y subplot(m,n,p) Creates an axes in the pth pane of a figure divided into an m-by-n matrix of rectangular panes. title Insert the title in the graph spectrogram (y, nwindow, overlap, nfft, fs, ‘yaxis’) Create a spectrogram of signal y Example: load handel; figure subplot(2,1,1) plot(y) title('handel in time domain') subplot(2,1,2) spectrogram(y, 256,128, 256, Fs, ‘yaxis’) title('Spectrogram of handel') 0 1 2 3 4 5 6 7 8x 104-1-0.500.51handel in time domainTimeFrequencySpectrogeam of handel0 1 2 3 4 5 6 7


View Full Document

UW EE 299 - Frequently used Matlab Commands

Download Frequently used Matlab Commands
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Frequently used Matlab Commands and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Frequently used Matlab Commands 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?