Skim Chapters 2, 3, & 4 Prior to Attempting
Total Page:16
File Type:pdf, Size:1020Kb
ELEC 206 HW #7 Matlab Homework 2 Due: Friday 28 Oct 2011 Skim chapters 2, 3, & 4 prior to attempting.
Part 1. Simple Script File Create a Script file (M- file) that contains the following code. Run the program by typing the name of the file (no extension) at the matlab command prompt. Don’t worry if some of the commands are still strange to you at this point. Print out both the m- file and the output plots for the report. %Simple script file % My Name 10/8/09 t = linspace(0,1, 501); % 501 pts of ‘t’ f1 = 2*pi * 10; % freq1 = 10 f2 = 2*pi*20; % freq2 = 20 x = cos(f1 .* t); % cosine at freq1 y = sin(f2 .* t); % sine at freq2 subplot(2,1,1) % first of two plots plot(t, x), title(‘cos at f = 10’), xlabel(‘Time(sec)’) % plot, title, and axis label subplot(2,1,2) % second of two plots plot(t,y), title(‘ sin at f = 20’) , xlabel(‘Time(sec)’) % plot, title, and axis label
Part 2. Build a Script File
Create a single Script file (M- file) that will generate and plot the functions listed below. Plot both functions on separate plot axes on the same figure window. Use appropriate title and axis labels. Print out the m- file and the output plots for the report.
1. Plot the function x(t) vs t for -10 <= t <= 10
x(t) = (3/2)t 2 + 4t - 5
2. Plot the function r(w) vs w for 0<= w <= 2*pi
r(w) = 2 sin(2w) + sin(5w) - cos( 2.5 w)
Part 3. Problem 4.10 of text
Create a single Script file (M- file) that will complete problem 4.10 of the text.
Report: 1) A cover sheet with your name. 2) Print out of part 1 m-file and plots 3) Print out of the part 2 m-file and plots. 4) Print out of the part 3 m-file and output.