Engr 101 Assignment 2 Assigned: November 9, 2015 Due: November 13, 2015 Download this page as a Word document from http://csserver.evansville.edu/~blandfor/EN101/index.htm. Work each problem by using MATLAB® as a calculator. Copy and paste your MATLAB® code and your results below each problem. Turn in the completed sheet. 1. Write an m-file to print the value of y when t goes from 0 to 1 in steps of 0.1 for the equation given by: y (t ) 2t cos(3t ) sin( t ) 2. Write an m-file to input a value for x from the user and print the following: • If x is in the range 0 ≤ x ≤ 10 print the absolute value of x. • If x is in the range 0 > x ≥ -10 print x3. • Otherwise if x is less than 40 but greater than 10 print x! • Otherwise, print the value of x. 3. Create a new m-file in MATLAB® and copy the code below into it. Name your m-file p3.m. Run your m-file from the command line and show what it produces. Can you explain this result? fs = 44100; T = 1/fs; f0 = 500; fmax = fs/2; terms = fix(fmax/f0); pts = fix(2/T); n = 1:pts; nT = n*T; w = 2*f0*pi; saw = zeros(1, length(nT)); for k = 1:terms saw = saw + 1/(2*k*pi)*sin(k*w*nT); end saw = saw/max(abs(saw)); t = 0:T:(pts - 1)*T; figure(1);clf; plot(t, saw); axis([0 2/f0 -1.5 1.5]); xlabel('time in seconds'); ylabel('voltage'); title('Sawtooth wave in time');