1 / 18

Introduction to Matlab II

Introduction to Matlab II. EE 2303 Lab. Basic Matlab Review. Data file input/output string, char, double, struct  Types of variables load, save  directory/workspace data file movement Navigation/workspace commands clear – clears workspace of all variables

mirari
Download Presentation

Introduction to Matlab II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Matlab II EE 2303 Lab

  2. Basic Matlab Review • Data file input/output • string, char, double, struct Types of variables • load, save directory/workspace data file movement • Navigation/workspace commands • clear – clears workspace of all variables • close all – close all figure-windows • Up-arrow – scroll through recently used command

  3. Basic Matlab Review • Fundamentals of matrix computing • [ ], Brackets are used to form vectors and matrices • { }, Curly braces are used in cell array assignment • ( ), Parentheses • Enclose arguments of functions • Enclose subscripts of vectors and matrices • Indicate precedence in arithmetic expressions

  4. Basic Matlab Review • Plotting functions • plot(), stem() 1-dimensional graphing • mesh(), imagesc() 2-dimensional visualization

  5. Creating Arrays • cell(M,N) create M-by-N cell array of empty matrices • Individual cells can be any matlab data type • Enables matrices with mixed elements e.g.

  6. Creating Arrays zeros(M,N) create M-by-N zeros matrix ones(M,N) create M-by-N ones matrix

  7. User Interface Commands • More user-friendly • Looks slicker • Principal UI commands • uigetfile() – retrieve files • questdlg() – input logical buttons • inputdlg()– input values

  8. uigetfile() • Retrieves file via browser window Ex: [audio_input, pathname] = uigetfile('*.wav', 'Please select a wav-file');

  9. inputdlg() • Parameter input dialog  outputs cell array Ex: lpdlg = inputdlg({'Enter cutoff frequency(in Hz)'},'Low Pass Filter Parameters',1,{'1000'});

  10. questdlg() • Asks question – Yes-No-Cancel by default Ex: isdlg = questdlg('Would you like to listen to your input signal?', 'Input sound');

  11. guide • GUI Design Environment • Alter .fig files • Design self-contained gui’s

  12. Debug Mode • Used for scripts

  13. Complex Numbers For a complex signal x of size N… • real() -- outputs real components • imag() – outputs imaginary components • abs() – yields magnitude • angle() – yields phase of signal By default, i and j are both set to sqrt(-1) Z = x + j*y can also be written: Z = (x,y) essentially a 2d matrix

  14. Discrete Fourier Transform • Used to find frequency response of digital signals • Discrete signal input  DFT  discrete frequency response • Matrix form of DFT:

  15. FFT Example Create an example signal: t = 0:0.001:0.6; x = sin(2*pi*50*t) + … sin(2*pi*120*t); y = x + 2*randn(size(t)); plot(1000*t(1:50),y(1:50)) title('Signal Corrupted with Zero-Mean Random Noise') xlabel('time (milliseconds)')

  16. FFT Example Now find the frequency response using the DFT Y = fft(y,512); Pyy = Y.* conj(Y) / 512; f = 1000*(0:256)/512; plot(f,Pyy(1:257)) title('Frequency content of y') xlabel('frequency (Hz)')

  17. Lab Exercise • The goal of this lab is to expand your Matlab repertoire through: • Debugging a faulty script • Creating a user interface script • Creating an audio-Input script

  18. Approximating Reality EE 2303 Lab References: Oppenheim, Schafer. Discrete-Time Signal Processing. 2nd Edition, 1999, Prentice-Hall. Mathworks Home Page: www.mathworks.com

More Related