function [sys,x0,str,ts]=exp_pidf(t,x,u,flag)
switch flag,
case 0 % initializations
[sys,x0,str,ts] = mdlInitializeSizes;
case 2 % discrete states updates
sys = mdlUpdates(x,u);
case 3 % computation of control signal
% sys = mdlOutputs(t,x,u,kp,ki,kd,MTab);
sys=mdlOutputs(t,x,u);
case {1, 4, 9} % unused flag values
sys = [];
otherwise % error handling
error(['Unhandled flag = ',num2str(flag)]);
end;
%==============================================================
% when flag=0, perform system initialization
%==============================================================
function [sys,x0,str,ts] = mdlInitializeSizes
sizes = simsizes; % read default control variables
sizes.NumContStates = 0; % no continuous states
sizes.NumDiscStates = 3; % 3 states and assume they are the P/I/D components
sizes.NumOutputs = 1; % 2 output variables: control u(t) and state x(3)
sizes.NumInputs = 2; % 4 input signals
sizes.DirFeedthrough = 1;% input reflected directly in output
sizes.NumSampleTimes = 1;% single sampling period
sys = simsizes(sizes); %
x0 = [0; 0; 0]; % zero initial states
str = [];
ts = [-1 0]; % sampling period
%==============================================================
% when flag=2, updates the discrete states
%==============================================================
function sys = mdlUpdates(x,u)
T=0.001;
sys=[ u(1);
x(2)+u(1)*T;
(u(1)-u(2))/T];
%==============================================================
% when flag=3, computates the output signals
%==============================================================
function sys = mdlOutputs(t,x,u,kp,ki,kd,MTab)
kp=1.5;
ki=2.0;
kd=0.05;
%sys=[kp,ki,kd]*x;
sys=kp*x(1)+ki*x(2)+kd*x(3);
pid1.rar_ pid1_Matlab simulink_PID仿真_pid控制m文件_pid控制实例
版权申诉
5星 · 超过95%的资源 125 浏览量
2022-09-24
12:43:19
上传
评论
收藏 43KB RAR 举报
朱moyimi
- 粉丝: 63
- 资源: 1万+
最新资源
- 6_Advertising-gd_LearningRate.ipynb
- BrushNet电商公司和摄影公司都在用的AI工作流
- 12_base.apk
- 520马上到了两款动态爱心表白HTML代码(附源码)李峋同款爱心,快送给你爱的她或(他)吧12 情侣纪念日代码.zip
- 电子设计竞赛的单相不间断电源设计
- cutcamera1715961370938.png
- 基于MATLAB的图像处理课程设计报告.doc
- tensorflow-gpu-2.6.0-cp38-cp38-manylinux2010-x86-64.whl
- mmexport1715960553858.png
- tensorflow-gpu-2.6.0-cp37-cp37m-manylinux2010-x86-64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈