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

📄 dcl_pend.m

📁 三级倒立摆的稳定
💻 M
字号:
% Simulation of the sampled-data closed-loop system
%
sim_pend
%
% discretization interval
Ts = input ('Enter sampling period Ts = ');
KD = samhld(K,Ts);
%
% response to the reference input
timedata = 0;
ti = Ts/10;
tf = 20;
stepdata2 = -0.1;
stepdata3 = 0.2;
ref1 = 0;
ref2 = step_tr(timedata,stepdata2,ti,tf);
ref3 = step_tr(timedata,stepdata3,ti,tf);
ref = abv(ref1,ref2,ref3);
pert = abv(0,0,0,0,0,0,0,0);
dist = abv(0,0,0);
noise = abv(0,0,0);
[y,w,v] = sdtrsp(pend_sm,KD,abv(pert,ref,dist,noise),Ts,tf,ti);
figure(1)
vplot(sel(y,9,1),'c--',sel(y,10,1),'g-.',sel(y,11,1),'r-')
grid
title('Closed-loop transient response')
xlabel('Time (secs)')
ylabel('y1, y2, y3 (rad)')
%legend('y1','y2','y3')
figure(2)
vplot(sel(v,1,1),'r-',sel(v,2,1),'c--')
grid
title('Closed-loop control')
xlabel('Time (secs)')
ylabel('u1, u2 (V)')
%legend('u1','u2')
%
% response to the disturbance
pert = abv(0,0,0,0,0,0,0,0);
ref = abv(0,0,0);
dist = abv(0.1,0.1,0.1);
noise = abv(0,0,0);
[y,w,v] = sdtrsp(pend_sm,KD,abv(pert,ref,dist,noise),Ts,tf,ti);
figure(3)
vplot(sel(y,9,1),'c--',sel(y,10,1),'g-.',sel(y,11,1),'r-')
grid
title('Closed-loop disturbance response')
xlabel('Time (secs)')
ylabel('y1, y2, y3 (rad)')
%legend('y1','y2','y3')
figure(4)
vplot(sel(v,1,1),'r-',sel(v,2,1),'c--')
grid
title('Closed-loop control')
xlabel('Time (secs)')
ylabel('u1, u2 (V)')
%legend('u1','u2')
%
% response to the noise
pert = abv(0,0,0,0,0,0,0,0);
ref = abv(0,0,0);
dist = abv(0,0,0);
rand('state',0)
tf = 20;
ti = 0.01;
time = [ti:ti:tf];
noise1 = 0;
noise2 = 0;
noise3 = siggen('1.3*(rand-0.5)',time);
noise = abv(noise1,noise2,noise3);
[y,w,v] = sdtrsp(pend_sm,KD,abv(pert,ref,dist,noise),Ts,20,Ts/10);
figure(5)
vplot(sel(y,11,1),'r-')
axis([0 20 -0.0006 0.0008])
grid
title('Closed-loop noise response')
xlabel('Time (secs)')
ylabel('y3 (rad)')
figure(6)
subplot(2,1,1)
vplot(sel(y,12,1),'r-')
axis([0 20 -0.003 0.002])
grid
title('Closed-loop control')
xlabel('Time (secs)')
ylabel('u_1 (V)')
subplot(2,1,2)
vplot(sel(y,13,1),'c-')
axis([0 20 -0.01 0.01])
grid
xlabel('Time (secs)')
ylabel('u_2 (V)')

⌨️ 快捷键说明

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