自动控制理论的MATLAB仿真实例(二)

%求方程的解
x=sym('x');
fx=(3*x*x+2*x)*(x*x+2.32*x+4)-(2*x+2.32)*(x*x*x+x*x)
fx = 
expand(fx)
ans = 
den=[1 116/25 358/25 8];
roots(den)
ans = 3×1 complex
-1.9750 + 2.7738i
-1.9750 - 2.7738i
-0.6900 + 0.0000i
 
 
 
%绘制根轨迹图
num=[1 1 0 0];
den=[1 2.32 4];
s1=tf(num,den)%多项式相除,得分式
s1 =

s^3 + s^2
----------------
s^2 + 2.32 s + 4

Continuous-time transfer function.
rlocus(s1)
 
%绘制根轨迹图
num=1;
den=conv([1 1],[1 6 10])%展开多项式
den = 1×4
1 7 16 10
 
 
s1=tf(num,den)
s1 =

1
-----------------------
s^3 + 7 s^2 + 16 s + 10

Continuous-time transfer function.
rlocus(s1)
 
%绘制伯德图,求相角裕度、增益裕度
num=1;
den=conv([1 1],conv([0.8 1],[0.2 1]));
s1=tf(num,den);
bode(s1)
hold on
margin(s1)
hold off
 
%反馈校正
num=100;
den=conv([1 0],conv([0.1 1],[0.0067 1]));
s1=tf(num,den)
s1 =

100
----------------------------
0.00067 s^3 + 0.1067 s^2 + s

Continuous-time transfer function.
hold on;
num1=0.0167*[1 0 0];
den1=[0.2 1];
s2=tf(num1,den1)
s2 =

0.0167 s^2
----------
0.2 s + 1

Continuous-time transfer function.
s0=feedback(s1,s2)
s0 =

20 s + 100
------------------------------------------
0.000134 s^4 + 0.02201 s^3 + 1.977 s^2 + s

Continuous-time transfer function.
bode(s0)
 
%非最小相位系统
close all
num=[1 1];
den=[2 1];
s1=tf(num,den)
s1 =

s + 1
-------
2 s + 1

Continuous-time transfer function.
bode(s1)
hold on;
num=-[1 -1];
den=[2 1];
s1=tf(num,den)
s1 =

-s + 1
-------
2 s + 1

Continuous-time transfer function.
bode(s1)
hold off
 
%根轨迹&阶跃响应
num=[1 1];
den=conv([1 0],[1 -3]);
s1=tf(num,den);
rlocus(s1)
num=9*[1 1];
den=conv([1 0],[1 -3]);
s1=tf(num,den);
H=1;
cloop=feedback(s1,H);
step(cloop)
 
%滞后系统根轨迹
num=1;
den=[1 1];
s1=tf(num,den)
s1 =

1
-----
s + 1

Continuous-time transfer function.
[num1,den1]=pade(1,10);
sdelay=tf(num1,den1);
s2=s1*sdelay;
rlocus(s2);
 
%单位脉冲响应
close all
num=25;
den=[1 4 25];
s1=tf(num,den);
step(s1)
hold on
impulse(s1)
hold off
legend({'step','impulse'});
 
%求截止频率
num=100*[0.25 1];
den1=conv([1 0 0],[0.005 1]);
s1=tf(num,den1);
bode(s1)
[mag,phase,w]=bode(s1);
[l,c]=size(mag);
mag1=zeros(c,1);
for i=1:c
mag1(i)=20*log10(mag(1,1,i));
end
wc=interp1(mag1,w,0,'spline')
wc = 25.1177

猜你喜欢

转载自www.cnblogs.com/dingdangsunny/p/12318856.html