MATLAB at CSU

 

1.      What is MATLAB?

·        MATrix LABoratory

·        Interpretive Language

·        Basic data structure is a matrix

 

2.      Programs and Functions

·        Command Session              : run command after command

·        Function = .m file                : variables in and variables out

·        Script File  = .m file            : program (set of instructions)

 

3.      What can you do?(EE311 / EE312)

·        Circuits, Electronics, Systems, Communication, Antennas, etc.

·        Very powerful plotting routines

·        Many useful .m files and functions

 

4.      Logging On and Creating a Folder

·        To log on, press ‘Ctrl-Alt-Delete’

·        Enter your ‘username’ and ‘password’, then click on ‘OK’

·        To create a folder, Double-click on the icon in the upper left hand corner

·        Double-click on your U:\ Drive (username on ‘megatera’ U:’)

·        Pull down ‘File’, go to ‘New’ and then to ‘Folder’

·        Name your ‘New Folder’ (eg. M_demo). Click on folder icon

 

5.      Starting Internet Explorer and Downloading a demo

·        Click on the Internet Explorer Icon next to start (second icon from the left)

·        Click on link ‘College of Engineering’,

·        Then click on ‘Electrical and Computer Engineering’

·        Click on ‘Curriculum’, go to  ‘Courses’

·        Scroll down to and click on ‘EE 311 Linear Systems Analysis I

·        Click on ‘Computer Labs’ and then on ‘ Computer Lab #1 …’

·        Click on ‘LAB NOTES’ and then on ‘Lab Notes For Computer Lab 1.doc’, Scroll thru to see pretty pictures.

·        Use back arrow to return to ‘Lab Notes and Demos’, click on ‘rootdemo.m’

·        A window will pop up. Click ‘OK’ to save the file

·        From here, double-click on ANDERxxx(username), then on your U:\ Drive

·        Double-click on the folder you just created and click on ‘Save’. Then close.

 

6.      Starting MATLAB and Running m-files

·        Open ‘Start’, go to ‘Engineering Applications’ and then to ‘MATLAB R12’

·        Click on ‘Current Directory’ tab, Maximize window size.

·        Click on ‘d:\matlabR12\work’, type ‘u:\’ and press ‘Enter’

·        Double-click on your new folder (eg. M_Demo)

·        Go to the command window (when you see ») on the right and type ‘rootdemo’ to run the program

·        To run another file, click on the tab ‘Lab Notes and …” on the bottom of the screen

·        Download another file to your directory (eg. ‘app_expj.m’) Click on ‘OK’, ‘Save’, and then ‘Close’

·        Go back to MATLAB and type ‘app_expj’ (underneath where you typed ‘rootdemo’)

 

7.       Program Exercise 1: Digital Oscilloscope: vs. t

·        Use the command window [ » ] to create a signal

·        Need digital time base:

·        In MATLAB, this is coded as:

»f=440; % musical note A

»t=[0:0.01/f:4/f]; % 100 samples per period & 4 periods

» x=sin(2*pi*f*t);

»figure            % creates a new figure

»plot(t,x)         % Shown below

 

 

8.      Program Exercise 2: Complex Frequency Response of an Audio Amplifier: .

·        Create your own function, an m-file

·        Need frequency base:         % 10 zero crossings

·        Click on ‘File’, go to ‘New’, and then to ‘M-file’. In this editor, type

 

function plotSINC(T)

% plot complex frequency response of audio amplifier

% H(f)=T*sin(pi*f*T)/(pi*f*T) for roughly

% 5 bandwidths worth of frequency

 

f_limit=5/T;

f_step=.1/T;

f=[-f_limit:f_step:f_limit];  % create frequency vector in units of hertz

H_f=T*sinc(f*T);               % sinc is built-in to MATLAB

 

figure                                % plot results

title('Complex Frequency Response of an Audio Amplifier')

hold on

axis([-f_limit f_limit -.3*T T])

plot(f,H_f)

plot([-f_limit f_limit],[0 0],'k')

xlabel('\it{f}'), ylabel('{\it{H}} ( {\it{f}} )')

 

·        Go to ‘File’, click on ‘Save’, label file as ‘plotSINC’.

·        Click on MATLAB on the bottom of screen

·        For T = 2, we would type the following (shown below):

» plotSINC(2)