Project 1

wo=pi*1;

dt=0.005;

t=0:dt:10;

L=length(t);

tp=[2*t(1):dt:2*t(L)];

%x=(1.*(upulse(t)-2*upulse(t-1)+upulse(t-2)));

x=(sin(wo*t)+2*cos(wo*t)+ustep(t));

h=ustep(t).*(sin(wo*t));

y=(dt*conv(x,h));

y(5/dt)

 

subplot(4,1,1), plot(t,x),axis( [-2, 12, -2, 5]), ylabel(‘x(t)’), grid

subplot(4,1,2), plot(t,h),axis( [-2, 12, -4, 4]), ylabel(‘h(t)’), grid

subplot(4,1,3), plot(t,x, ‘:’,t,h,’-‘),axis( [-2, 12, -4, 4]), ylabel(‘x(t), y(t)’)

subplot(4,1,4), plot(tp,y),axis( [-2, 25, -5, 5]), ylabel(‘y=h*x’),grid

for t=0:dt:10,

%x=(1.*(upulse(t)-2*upulse(t-1)+upulse(t-2)));

x=(1.*(3*upulse(t)-2*upulse(t-1)+2*upulse(t-2)-upulse(t-5)+2*upulse(t-6)));

power=(abs(x))^2*0.5;

power=power+power;

end;

end;

%power = abs(sin(wo*t))^2;

fprintf(‘power of periodic signal is %f \n’,power);

%plot(t,x), hold, plot(t,h);