⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iden_c21d.m

📁 状态反馈matlab仿真程序
💻 M
字号:
%-----------------------------------------------------------------------
%    Model Identification Using Relay Feed-back with delay width 'h'
%-----------------------------------------------------------------------
% Note: This program is available only after the Chap21.mdl is executed 
%                      which output the 'y' value

% Give the value according to the parameters in Chap21.mdl
d=10;
h=0.15;
Tal=95;
dm=d/4;

% Plot the Bode Graph of the Real Object
clf
w=logspace(-2,2,200)';
num1=1;den1=[1 3 2];tao1=20,
[r1,i1]=nyquist(num1,den1,w);
rd1=real((r1+j*i1).*exp(-j*w*tao1));
id1=imag((r1+j*i1).*exp(-j*w*tao1));
for i=2:length(id1)
   if (id1(i-1)*id1(i)<0 & rd1(i)<0)
      i0=i;
      break;
   end
end
A0=-rd1(i0),
wc0=w(i0),
plot(rd1,id1,'r-'),
xlabel('Re'); ylabel('Im'); Title('Nyquist Graph');

% Identification using relay feedback output response
tt=[0:0.1:10];
z=step(num1,den1,tt);
K=z(100,1);

m=0; n=0;
dy=y(2:length(y))-y(1:(length(y)-1));
for i=2:1:(length(y)-1)
   if (y(i-1)*y(i)<0 & abs(dy(i))>0) 
      m=m+1;
      tm(m)=i;
   end
   if (dy(i-1)*dy(i)<0 & abs(y(i))>dm)  % 'dm' is cariable with 'd'
      n=n+1;
      ym(n)=y(i);
   end
end

T0=Tal*(tm(m)-tm(m-2))/(length(y)-1);  % Tal must be same as the time in Chap21
w0=2*pi/T0,
a=abs(ym(n));
A1=(pi*a)/(4*d);            % 'd' is variable
%alfa=(pi-asin(h/a))/pi;    % To correct the value of 'A'
%A=A1/alfa;
A=A1,
T=sqrt((K/A)^2-1)/w0;
tao2=(pi-atan(w0*T))/w0;
num2=K;
den2=[T 1];

% Plot the Bode Graph of the Identified Model
hold on;
[r2,i2]=nyquist(num2,den2,w);
rd2=real((r2+j*i2).*exp(-j*w*tao2));
id2=imag((r2+j*i2).*exp(-j*w*tao2));
plot(rd2,id2,'b:'),

% Plot the graph of the output value
figure(2);
t=[0:Tal/(length(y)-1):Tal];
plot(t,y); grid,
xlabel('t'); ylabel('y'); Title('Output Oscillation Curve');

% Calculate the error of A and wo
err_A=(A-A0)/A0,
err_w0=(w0-wc0)/wc0,
beta_A=A0/A,
beta_w0=wc0/w0,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -