%Part 1
T=1/8000;
t=-.2:T:.2;
x=10*cos(2*pi*15*t+1.5)+4*cos(2*pi*25*t-.5)+6*cos(2*pi*30*t-1);
y=4*cos(2*pi*15*t+.8)+6*cos(2*pi*25*t+.4)+8*cos(2*pi*30*t-1.6);
plot(t,x,t,y,'-r');
legend('x','y');
xlabel('t');
z=10*cos(2*pi*15*t+.8)+4*cos(2*pi*25*t+.4)+6*cos(2*pi*30*t-1.6);
figure
plot(t,x,t,z,'-g');
legend('x','z');
xlabel('t');
%Part 2
clear all
T=.001;
t=-.5:T:.5;
x=-1.3-8.4*cos(1.5*pi*t-.45)+4.2*sin(23*pi*t+2.8)-4.8*sin(12*pi*t-1.3);
figure
plot(t,x);
title('Part 2 x(t)');
f=[0 .75 6 11.5];
A=[-1.3 8.4 4.8 4.2];
Ph=[0 -.45+pi -1.3+pi/2 2.8-pi/2];
figure
stem(f,A);
title('Part 2 single sided Amplitude');
figure
stem(f,Ph);
title('Part 2 single sided Phase');
clear all
f=[-11.5 -6 -.75 0 .75 6 11.5];
A=[2.1 2.4 4.2 -1.3 4.2 2.4 2.1];
Ph=[-(2.8-pi/2) -(-1.3+pi/2) -(-.45+pi) 0 -.45+pi -1.3+pi/2 2.8-pi/2];
figure
stem(f,A);
title('Part 2 double sided Amplitude');
figure
stem(f,Ph);
title('Part 2 double sided Phase');
%Part 3
clear all
T=.001;
t=-22:T:10;
x1=3.9*cos(.2*pi*t-1.5);
x2=3.75*cos(.5*pi*t-.6);
x3=.5*cos(1.2*pi*t+.2);
x_imp = zeros(size(t));
x_imp(t==0) = 1/T;
H=zeros(size(t));
H(1)=0;
H(2)=0;
for i=3:1:length(t)
H(i)=(x_imp(i)*(.9*T^2+.2*T)-.2*T*x_imp(i-1)-.3*H(i-2)+H(i-1)*(.6+.4*T))/(.3+.4*T+.8*T^2);
end
tc=-44:T:20;
z1=T*conv(x1,H);
A_max_z1 = max(z1);
z2=T*conv(x2,H);
A_max_z2 = max(z2);
z3=T*conv(x3,H);
A_max_z3 = max(z3);
figure
plot(t,x1)
hold on
plot(tc,z1,'-r')
xlim([-10 10])
title('x1 input and output')
legend('x','z');
xlabel('t');
hold off
figure
plot(t,x2)
hold on
plot(tc,z2,'-r')
xlim([-10 10])
title('x2 input and output')
legend('x','z');
xlabel('t');
hold off
figure
plot(t,x3)
hold on
plot(tc,z3,'-r')
xlim([-10 10])
title('x3 input and output')
legend('x','z');
xlabel('t');
hold off
%b
xtotal=x1+x2+x3;
ztotal=T*conv(xtotal,H);
figure
plot(t,xtotal)
hold on
plot(tc,ztotal,'-r')
title('total input and output')
legend('x','z');
xlabel('t');
hold off
%c
fi=[-.6 -.25 -.1 .1 .25 .6];
Ai=[.25 1.875 1.9 1.9 1.875 .25];
figure
stem(fi,Ai)
title('Input Amplitude Spectrum')
fo=fi;
Ao=[A_max_z3/2 A_max_z2/2 A_max_z1/2 A_max_z1/2 A_max_z2/2 A_max_z3/2];
figure
stem(fo,Ao)
title('Output Amplitude Spectrum')
%d
%For the input the significant bandwidth is .5 since the ys are all
%above our significance factor of .2
%For the output the significant bandwidth is .15 since y of the
%higher band is less than .2
0lasamitsu Jeremy Frazier https://marketplace.visualstudio.com/items?itemName=1vicacowo.Billion-Road-gratuita
ReplyDeletequimapartwor