Professional Documents
Culture Documents
Listing
Listing
t = -10:0.01:10;
f = -10:0.01:10;
n = 1;
for time = t;
if time < 0
u(n) = 0;
elseif time >= 0
u(n) = 1;
end
n = n+1;
end
figure(1),
plot(t,u)
a = 0.5;
f0 = 2;
x = exp(-a*t).*sin(2*pi*f0*t);
figure(2),
plot(t,x)
x_u = exp(-a*t).*(2*pi*f0*t).*u;
figure(3), plot(t,x_u)
figure(4)
plot(f,magX,f,phaseX)
Listing 2
n = 0:10;
theta_n = atan(-4*n);
C_n(n==0) = 0.504;
C_n(n~=0) = 0.504*2./sqrt(1+16*n(n~=0).^2);
k = 1;
for t = -2*pi:0.01:2*pi;
x(k) = C_n(n==0) + C_n(n~=0)*cos(2*n(2:end)*t + theta_n(2:end))';
k = k + 1;
end
figure(1)
subplot(2,1,1);
stem(n,C_n,'.k');
axis([-.5 10.5 0 .6]);
xlabel('n'); ylabel('C_n');
subplot(2,1,2);
stem(n,theta_n,'.k');
axis([-.5 10.5 -1.6 0]);
xlabel('n'); ylabel('\theta_n');
figure(2)
t = -2*pi:0.01:2*pi;
plot(t,x)
Listing 3
x=@(t) 1.0*((-1<=t)&(t<=1));
h=@(t) 1.0*((t<=3)&(t>=0)).*t/3;
delta=0.01;
tx=-5:delta:5;
th=-5:delta:5;
y=conv(x(tx),h(th))*delta;
ty=(tx(1)+th(1)):delta:(tx(end)+th(end));
figure(1)
subplot(3,1,1)
plot(tx,x(tx))
ylim([min(x(tx))-1,max(x(tx))+1]); grid on
subplot(3,1,2)
plot(th,h(th))
ylim([min(h(th))-1,max(h(th))+1]); grid on
subplot(3,1,3)
plot(ty,y);
ylim([min(y)-1,max(y)+1]); grid on