This commit is contained in:
iridiumR 2022-05-05 20:25:46 +08:00
parent 259423ad3f
commit 4f53b1ca67
2 changed files with 131 additions and 3 deletions

View file

@ -1,7 +1,5 @@
figure(1);
Ts = 1/50;
t = 0:Ts:10-Ts;
x = sawtooth(t,0.5);
sy
plot(t,x)
xlabel('Time (seconds)')
ylabel('Amplitude')

130
Matlab/lab2_ref.m Normal file
View file

@ -0,0 +1,130 @@
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;
%1.2齿
cn=(an^2+bn^2)^(1/2);
n=1:10;
cn1=subs(cn);
cn2=[0,cn1];
h=stem([0,n],cn2);
hold on;
plot([0,n],cn2)
title('')
xlabel('\omega');
ylabel('c_n');
%an00anpi
figure(2);
syms t w;
ft=exp(-3*t)*heaviside(t);
subplot(2,2,1);
ezplot(ft);
title('f(t)=e^-^3^tu(t)');
xlabel('t');
ylabel('f(t)');
Fw=fourier(ft);
w=-3:0.01:3;
Fw1=subs(Fw);
subplot(2,2,2);
plot(w,abs(Fw1));
title('');
xlabel('(\omega)');
ylabel('');
subplot(2,2,3);
plot(w,angle(Fw1)*pi/180);
title('');
xlabel('(\omega)');
ylabel('\phi');
figure(3);
syms t w tao;
tao=3;
Fw=tao*sin(tao*w/2)/(tao*w/2);
ft=ifourier(Fw,t);
subplot(2,2,1);
ezplot(ft,[-2,2]);
title('f(t)');
xlabel('t');
ylabel('f(t)');
subplot(2,2,2);
ezplot(Fw,[-10,10]);
title('');
xlabel('\omega');
subplot(2,2,3);
ezplot(abs(Fw),[-10,10]);
title('');
xlabel('(\omega)');
ylabel('');
subplot(2,2,4);
ezplot(angle(Fw),[-10,10]);
title('');
xlabel('\omega');
ylabel('\phi');
figure(4);
syms w t;
Fw=(1-j*w)/(1+j*w);
w=-5:0.01:5;
Fw1=subs(Fw);
subplot(2,1,1);
plot(w,abs(Fw1));
title('');
xlabel('(\omega)');
ylabel('|H(j\omega)|');
subplot(2,1,2);
plot(w,angle(Fw1)*pi/180);
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);
title('f(t)=e^-^2^tu(t)');
xlabel('t');
ylabel('f(t)');grid on;
Fw=fourier(ft);
Yw=Fw*Hw;
yt=ifourier(Yw,t);
subplot(2,2,3);
ezplot(yt,[-1,4,-1,0.5]);
title('');
xlabel('t');
ylabel('y_f(t)');grid on;
figure(6);
ft=exp(-2*t)*heaviside(t);
subplot(1,2,1);
ezplot(ft);
title('e^-^2^tu(t)');
xlabel('t');
ylabel('f(t)');grid on;
Fw=fourier(ft);
Yw=Fw*Hw;
yt=ifourier(Yw,t);
subplot(1,2,2);
ezplot(yt,[-1,4,-1,0.5]);
title('');
xlabel('t');
ylabel('y_f(t)');