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

📄 comparepid.m

📁 该程序用PID系统实现差动转向车辆控制
💻 M
字号:
%% Author: epokh
%% Website: www.epokh.org/drupy
%% This software is under GPL

clf;
close all;
K=[2,0.05,2];
decayInt=8;
scale=200;
time=[0 60];
[errInt1,errDiff1,Ct1,position_pts1]=simPID(K,time,0);
[errInt2,errDiff2,Ct2,position_pts2]=simPIDWindup(K,decayInt,scale,time,0);

maxCt1=max(Ct1);
minCt1=min(Ct1);
maxCt2=max(Ct2);
minCt2=min(Ct2);
Ct1norm=Ct1*(maxCt2-minCt2)/(maxCt1-minCt1);

subplot(2,1,1);
title('Control error comparison');
hold on;
grid on;
%%plot(Ct1-Ct2,'b--');
plot(Ct1norm,'r');
plot(Ct2,'g');
legend('Cerr normalized windup','Cerr no windup');
minCt2=minCt2+minCt2*0.001;
maxCt2=maxCt2+maxCt2*0.001;
axis([1 length(Ct2) min(Ct1norm) max(Ct1norm)]);
xlabel('sample time');
ylabel('normalized control error');
subplot(2,1,2);
%%now do a spectral analysis
CtFFT=fft(Ct2,512);
Pct=CtFFT.*conj(CtFFT)/512;
freq=1000*(0:256)/512;
plot(freq,Pct(1:257));
title('Frequency analysis of Ct no wind');
xlabel('frequency (Hz)');

⌨️ 快捷键说明

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