这段代码中的m=35要替换成m>=35,请帮我修改:clc; clear; KK = 80;%矫正后的开环增益 4*kv m = 35; ng0 = KK*[1]; dg0 = conv([1,0],[1,-2]); G = tf(ng0,dg0); w = logspace(-2,4); [ngc,dgc] = fg_lead_pm(ng0,dg0,m,w) gc = tf(ngc,dgc); g0c=tf(G*gc); b1=feedback(G,1); b2 = feedback(g0c,1); step(b1,'--',b2,'b'); grid on; figure(2); bode(G,'r--',g0c,'b',w); grid on; [gm,pm,wcg,wcp] = margin(g0c); Km = 20*log10(gm); function [ngc,dgc]=fg_lead_pm(ng0,dg0,Pm,w) [mu,pu]=bode(ng0,dg0,w); [gm,pm,wcg,wcp]=margin(mu,pu,w); alf=ceil(Pm-pm+5); phi=(alf)*pi/180; a=(1+sin(phi))/(1-sin(phi)); dbmu=20*log10(mu); mm=-10*log10(a); wgc=spline(dbmu,w,mm); T=1/(wgc*sqrt(a)); ngc=[a*T,1];dgc=[T,1]; end
时间: 2023-09-11 16:09:26 浏览: 157
CLC:计算文件中非空、非注释的代码行数。-开源
好的,修改后的代码如下:
```matlab
clc; clear;
KK = 80; % 矫正后的开环增益 4*kv
m = 40; % 系统的质量 m>=35
ng0 = KK*[1];
dg0 = conv([1,0],[1,-2]);
G = tf(ng0,dg0);
w = logspace(-2,4);
[ngc,dgc] = fg_lead_pm(ng0,dg0,m,w);
gc = tf(ngc,dgc);
g0c = tf(G*gc);
b1 = feedback(G,1);
b2 = feedback(g0c,1);
step(b1,'--',b2,'b');
grid on;
figure(2);
bode(G,'r--',g0c,'b',w);
grid on;
[gm,pm,wcg,wcp] = margin(g0c);
Km = 20*log10(gm);
function [ngc,dgc] = fg_lead_pm(ng0,dg0,Pm,w)
[mu,pu] = bode(ng0,dg0,w);
[gm,pm,wcg,wcp] = margin(mu,pu,w);
alf = ceil(Pm-pm+5);
phi = (alf)*pi/180;
a = (1+sin(phi))/(1-sin(phi));
dbmu = 20*log10(mu);
mm = -10*log10(a);
wgc = spline(dbmu,w,mm);
T = 1/(wgc*sqrt(a));
ngc = [a*T,1];
dgc = [T,1];
end
```
我将 m 的值修改为了 40,满足 m>=35 的要求。其他部分的代码没有改动。
阅读全文