Chap1_plotting_sol

# Chap1_plotting_sol - ’Time (sec)’ ) ylabel( ’x(t)’...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2. The following commands were saved in an M-file: % a) t1 = -8:-4; x1 = zeros(size(t1)); t2 = -4:3; x2 = t2+2; t3 = 3:8; x3 = t3-2; t = [t1 t2 t3]; x = [x1 x2 x3]; subplot(221),plot(t,x) xlabel( ’Time (sec)’ ) ylabel( ’x(t)’ ) title( ’a)’ ) % b) t = t+1; subplot(222),plot(t,x) xlabel( ’Time (sec)’ ) ylabel( ’x(t)’ ) title( ’b)’ ) % c) n1 = -6:1; x1 = zeros(size(n1)); n2 = 2:3; x2 = 2*n2-4; n3 = 4:8; x3 = 4-n3; n = [n1 n2 n3]; x = [x1 x2 x3]; subplot(223),stem(n,x) xlabel( ’n’ ) ylabel( ’x[n]’ ) title( ’c)’ ) % d) n = n-1; subplot(224),stem(n,x) xlabel( ’n’ ) ylabel( ’x[n]’ ) title( ’d)’ ),subplot(111) -10 -5 0 5 10 -2 0 2 4 6 Time (sec) x(t) a) -10 -5 0 5 10 -2 0 2 4 6 Time (sec) b) -10 -5 0 5 10 -4 -2 0 2 n x[n] c) -10 -5 0 5 10 -4 -2 0 2 n d)
3. 0 0.5 1 1.5 2 -4 -2 0 2 4 Time (sec) x(t) 1 a) 0 5 10 -4 -2 0 2 4 Time (sec) x[n] 1 b) 0 20 40 60 -2 -1 0 1 2 Time (sec) 1 c) -2 0 2 4 6 -4 -2 0 2 4 Time (sec) 1 d) 0 5 10 15 20 -4 -2 0 2 4 Time (sec) 1 e) -10 -5 0 5 10 -2 0 2 4 6 Time (sec) 1 f)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Here is an M-file that contains the script to plot generate these plots: % a) % period is 2/5, so 2 sec is long enough for plot t = 0:.4/100:2; x = 4*cos(5*pi*t-pi/4); subplot(2,2,1),plot(t,x) xlabel(
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ’Time (sec)’ ) ylabel( ’x(t)’ ) title( ’a)’ ) % b) % period is n=2, so plot for n=0 to 10 n=0:10; x = 4*cos(pi*n);; subplot(2,2,2),stem(n,x) xlabel( ’Time (sec)’ ) ylabel( ’x[n]’ ) title( ’ b)’ ) % c) % not periodic, try plotting for various lengths to see how it looks n=0:60; x = 2*sin(3*n);; subplot(2,2,3),stem(n,x) xlabel( ’Time (sec)’ ) ylabel( ’x(t)’ ) title( ’c)’ ) % d) % period is 2pi/4, so plot for 4 cycles T = 2*pi/4; t = -T:T/50:3*T; x = cos(4*t)+2*sin(8*t); subplot(2,2,4),plot(t,x) xlabel( ’Time (sec)’ ) ylabel( ’x(t)’ ) title( ’d)’ ) % e) % not periodic, see how it looks for various lengths t = 0:.02:20; x = 3*cos(4*t)+sin(pi*t); figure(2) % opens new window subplot(2,2,1),plot(t,x) xlabel( ’Time (sec)’ ) ylabel( ’x(t)’ ) title( ’e)’ ) subplot(1,1,1)...
View Full Document

## Chap1_plotting_sol - ’Time (sec)’ ) ylabel( ’x(t)’...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online