лаб 1
.docx
Код:
clc,clear
step = 0.01; max = 1000;
k = 1;
T = 0.2;
w=0:step:max;
U=k./((T*w).^2+1);
V=-k*T*w./((T*w).^2+1);
A=sqrt(U.^2+V.^2);
phi=atan(V./U)/pi*180;
L=20*log10(k./sqrt(1+(T*w).^2));
figure
subplot(5,1,1)
hold on, grid on
plot(w,U);
title('U(w)');
xlabel('w');
ylabel('U');
subplot(5,1,2)
hold on, grid on
plot(w,V);
title('V(w)');
xlabel('w');
ylabel('V');
subplot(5,1,3)
hold on, grid on
plot(w,A);
title('A(w)');
xlabel('w');
ylabel('A');
subplot(5,1,4)
hold on, grid on
plot(log10(w),L);
title('L(w)');
xlabel('log(w)');
ylabel('L');
subplot(5,1,5)
hold on, grid on
plot(w,phi);
title('phi(w)');
xlabel('w');
ylabel('phi');
figure
hold on, grid on
y=20*log10(k);
line([-2 log10(1/T)], [y y]);
line([log10(1/T) log10(10*1/T)], [y y-20]);
w=0:step:max;
L=20*log10(k./sqrt(1+(T*w).^2));
plot(log10(w),L);
xlabel('log(w)');
ylabel('L');
title('L(w)')
sys=tf([k],[T 1]);
ltiview('bode',sys)
Результат:
Код:
clc, clear
step = 0.01; max = 1000;
k = 3;
T = 0.2;
e=0.01;
w=0:step:max;
U=k*(1-(T*w).^2)./((1-(T*w).^2).^2+(2*e*T*w).^2);
V=-2*k*e*T*w./((1-(T*w).^2).^2+(2*e*T*w).^2);
A=sqrt(U.^2+V.^2);
phi=atan(V./U)/pi*180;
w=1:step:max+1;
L=20*log10(A);
figure
subplot(5,1,1)
hold on, grid on
plot(w,U);
title('U(w)');
xlabel('w');
ylabel('U');
subplot(5,1,2)
hold on, grid on
plot(w,V);
title('V(w)');
xlabel('w');
ylabel('V');
subplot(5,1,3)
hold on, grid on
plot(w,A);
title('A(w)');
xlabel('w');
ylabel('A');
subplot(5,1,4)
hold on,grid on
plot(log10(w),L);
title('L(w)');
xlabel('log(w)');
ylabel('L');
subplot(5,1,5)
hold on, grid on
w=0:step:1/T;
phi=-atan(2*k*e*T*w./((1-(T*w).^2)))/pi*180;
plot(w,phi);
w=1/T+step:step:100;
phi=(-pi-atan(2*k*e*T*w./((1-(T*w).^2))))/pi*180;
plot(w,phi);
title('phi(w)');
xlabel('w');
ylabel('phi');
figure
hold on, grid on
y=20*log10(k);
line([-2 log10(1/T)], [y y]);
line([log10(1/T) log10(10*1/T)], [y y-40]);
w=0:step:max;
L=20*log10(A);
plot(log10(w),L);
xlabel('log(w)');
ylabel('L');
title('L(w)');
sys = tf ([k], [T^2 (2*e*T) 1]);
ltiview('bode',sys)
Результат:
Код:
clc, clear;
k = 1;
T1 = 0.2;
T2 = 0.1;
e = 0.01;
sys = @(w)( (k*1j*w) ./ ( (T1*1j*w + 1) .* (1-T2^2*w.^2+2*T2*e*1j*w) ));
W = @(d)(sys(d));
phi = @(d)(angle(W(d)));
U = @(d)(real(W(d)));
V = @(d)(imag(W(d)));
A = @(d)(sqrt(U(d).^2 + V(d).^2));
L = @(d)(20*log10(A(d)));
lw = logspace(-3, 3, 10000);
figure()
semilogx(lw, L(lw));
title('L(jw)'); xlabel('w'); grid on; hold on;
v1 = 20*log10(k*lw(1));
vend = 20*log10(k*lw(end));
u1 = -20*log10((T1*T2^2*lw(1)^2)/k);
uend = -20*log10((T1*T2^2*lw(end)^2)/k);
plot([lw(1), lw(end)], [v1 vend],'r');
plot([lw(1), lw(end)], [u1 uend],'y');
legend('L(w)', 'as 1', 'as 2');
figure
phi1 = @(d)(pi/2 + d*0);
phi2 = @(d)(angle(W(1 ./ (T1*1j*d+1) )));
phi3 = @(d)(angle(W(1 ./ (1-(T2*d).^2+2*T2*e*1j*d) )));
w = 0.01:0.001:100;
subplot(4,1,1)
plot(w, phi1(w));
grid on;
xlabel('w');
title('k*p');
subplot(4,1,2)
plot(w, phi2(w));
grid on;
xlabel('w');
title('(T1*p+1)^-^1');
subplot(4,1,3)
plot(w, phi3(w));
grid on;
xlabel('w');
title('( (T2*p)^2 + 2*T2*s*p + 1)^-^1');
subplot(4,1,4)
plot(w, phi(w));
grid on;
xlabel('w');
title('sys');
Код:
clc,clear
k = 1;
T1 = 0.2;
T2 = 0.1;
e=0.01;
sys=tf(k)
ltiview('step',sys);
sys=tf(k, [T1 1])
ltiview('step',sys);
sys=tf(k,[T2^2 2*e*T2 1])
ltiview('step',sys);
Результат:
Transfer function:
1
Transfer function:
1
---------
0.2 s + 1
Transfer function:
1
----------------------
0.01 s^2 + 0.002 s + 1