This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/Matlab/sig_sys/lab2_ref.m

129 lines
2.2 KiB
Mathematica
Raw Normal View History

2022-05-05 12:25:46 +00:00
figure(1);
syms t n T;
f1=4/T*t+1;
f2=-4/T*t+1;
a0=(int(f1,-T/2,0)+int(f2,0,T/2))/T;
ya1=f1*cos(n*2*pi/T*t);
ya2=f2*cos(n*2*pi/T*t);
yb1=f1*sin(n*2*pi/T*t);
yb2=f2*sin(n*2*pi/T*t);
an=(int(ya1,-T/2,0)+int(ya2,0,T/2))/T*2;
bn=(int(yb1,-T/2,0)+int(yb2,0,T/2))/T*2;
cn=(an^2+bn^2)^(1/2);
n=1:10;
cn1=subs(cn);
cn2=[0,cn1];
h=stem([0,n],cn2);
plot([0,n],cn2)
title('')
xlabel('\omega');
ylabel('c_n');
figure(2);
2022-05-11 13:19:35 +00:00
syms t;
2022-05-05 12:25:46 +00:00
ft=exp(-3*t)*heaviside(t);
2022-05-11 13:19:35 +00:00
subplot(3,1,1);
2022-05-05 12:25:46 +00:00
ezplot(ft);
2022-05-11 13:19:35 +00:00
title('');
2022-05-05 12:25:46 +00:00
xlabel('t');
ylabel('f(t)');
2022-05-11 13:19:35 +00:00
F=fourier(ft);
2022-05-05 12:25:46 +00:00
w=-3:0.01:3;
2022-05-11 13:19:35 +00:00
F1=subs(F);
subplot(3,1,2);
plot(w,abs(F1));
2022-05-05 12:25:46 +00:00
title('');
2022-05-11 13:19:35 +00:00
xlabel('');
2022-05-05 12:25:46 +00:00
ylabel('');
2022-05-11 13:19:35 +00:00
subplot(3,1,3);
plot(w,angle(F1)*pi/180);
2022-05-05 12:25:46 +00:00
title('');
2022-05-11 13:19:35 +00:00
xlabel('');
ylabel('');
2022-05-05 12:25:46 +00:00
figure(3);
2022-05-11 13:19:35 +00:00
syms t w;
2022-05-05 12:25:46 +00:00
tao=3;
2022-05-11 13:19:35 +00:00
F=tao*sin(tao*w/2)/(tao*w/2);
ft=ifourier(F,t);
2022-05-05 12:25:46 +00:00
subplot(2,2,1);
ezplot(ft,[-2,2]);
2022-05-11 13:19:35 +00:00
title('');
2022-05-05 12:25:46 +00:00
xlabel('t');
ylabel('f(t)');
subplot(2,2,2);
2022-05-11 13:19:35 +00:00
ezplot(F,[-10,10]);
2022-05-05 12:25:46 +00:00
title('');
xlabel('\omega');
subplot(2,2,3);
2022-05-11 13:19:35 +00:00
ezplot(abs(F),[-10,10]);
2022-05-05 12:25:46 +00:00
title('');
2022-05-11 13:19:35 +00:00
xlabel('');
2022-05-05 12:25:46 +00:00
ylabel('');
subplot(2,2,4);
2022-05-11 13:19:35 +00:00
ezplot(angle(F),[-10,10]);
2022-05-05 12:25:46 +00:00
title('');
xlabel('\omega');
2022-05-11 13:19:35 +00:00
ylabel('');
2022-05-05 12:25:46 +00:00
figure(4);
syms w t;
2022-05-11 13:19:35 +00:00
F=(1-j*w)/(1+j*w);
2022-05-05 12:25:46 +00:00
w=-5:0.01:5;
2022-05-11 13:19:35 +00:00
F1=subs(F);
2022-05-05 12:25:46 +00:00
subplot(2,1,1);
2022-05-11 13:19:35 +00:00
plot(w,abs(F1));
2022-05-05 12:25:46 +00:00
title('');
xlabel('(\omega)');
ylabel('|H(j\omega)|');
subplot(2,1,2);
2022-05-11 13:19:35 +00:00
plot(w,angle(F1)*pi/180);
2022-05-05 12:25:46 +00:00
xlabel('(\omega)');
ylabel('\phi');
figure(5);
syms w t;
Hw=(1-j*w)/(1+j*w);
ht=ifourier(Hw,t);
subplot(2,2,1);
ezplot(ht);
title('');
xlabel('t');
ylabel('h(t)');
ft=exp(-2*t)*heaviside(t);
subplot(2,2,2);
ezplot(ft);
2022-05-11 13:19:35 +00:00
title('');
2022-05-05 12:25:46 +00:00
xlabel('t');
ylabel('f(t)');grid on;
2022-05-11 13:19:35 +00:00
F=fourier(ft);
Yw=F*Hw;
2022-05-05 12:25:46 +00:00
yt=ifourier(Yw,t);
subplot(2,2,3);
ezplot(yt,[-1,4,-1,0.5]);
title('');
xlabel('t');
2022-05-11 13:19:35 +00:00
ylabel('y_f(t)');
2022-05-05 12:25:46 +00:00
figure(6);
2022-05-11 13:19:35 +00:00
syms w t;
2022-05-05 12:25:46 +00:00
ft=exp(-2*t)*heaviside(t);
subplot(1,2,1);
ezplot(ft);
2022-05-11 13:19:35 +00:00
title('F');
2022-05-05 12:25:46 +00:00
xlabel('t');
ylabel('f(t)');grid on;
2022-05-11 13:19:35 +00:00
F=fourier(ft);
Yw=F*Hw;
2022-05-05 12:25:46 +00:00
yt=ifourier(Yw,t);
subplot(1,2,2);
ezplot(yt,[-1,4,-1,0.5]);
title('');
xlabel('t');
ylabel('y_f(t)');