PID control of Gaussian distribution input in MATLAB

Source: Internet
Author: User

A random array of matlab

s=1:1:500;
in = 0.1*randn (1,500) +1;
Plot (s,in, ' * ');

hist (in,20);

Second, PID control

Online Source:

Clear All;close ALL;TS=0.001;SYS=TF (5.235e005,[1,87.35,1.047e004,0]);% build transfer function dsys=c2d (sys,ts, ' z ');% The continuous time model is converted into a discrete time model, the sampling time is ts=0.001[num,den]=tfdata (Dsys, ' V '), and the numerator denominator u_1=0.0;u_2=0.0;u_3=0.0;y_1=0.0;y_2=0.0 is obtained after the dispersion; y_3=0.0;x=[0,0,0] '; error_1=0;for k=1:1:500time (k) =k*ts;rin (k) = 1; The% input is (0.8,1.2) the random number of the kp=0.6;ki=0.001;kd=0.001 distribution; The p,i,d parameter of the% setting is U (k) =kp*x (1) +kd*x (2) +ki*x (3); %pid Controller%linear Model Linear models yout (k) =-den (2) *y_1-den (3) *y_2-den (4) *y_3+num (2) *u_1+num (3) *u_2+num (4) *u_3;error (k) =rin (k)-yout (k);%return of Parametersu_3=u_2;u_2=u_1;u_1=u (k); Y_3=y_2;y_2=y_1;y_1=yout (k); X (1) =error (k); %calculating Px (2) = (Error (k)-error_1)/ts; %calculating x (3) =x (3) +error (k) *ts; %calculating Ixi (k) =x (3); Error_1=error (k); Endfigure (1);p lot (Time,rin, ' B ', time,yout, ' R '); Xlabel (' Time (s) '); Ylabel (' Rin,yout ')

  

Three, Gaussian distribution of input

%pid controlerclear All;close all;s=1:1:500;in = 0.1*randn (1,500) +1; % of 500 (0.95,1.05) of the random number of the distribution of the plot (S,in, ' * '); grid ONTS=0.001;SYS=TF (5.235e005,[1,87.35,1.047e004,0]);% Build transfer function dsys= C2D (sys,ts, ' z ');% converts a continuous time model into a discrete time model with a sampling time of ts=0.001[num,den]=tfdata (Dsys, ' V '), and a percentage of the numerator denominator u_1=0.0;u_2=0.0;u_3=0.0 ; y_1=0.0;y_2=0.0;y_3=0.0;x=[0,0,0] '; error_1=0;for k=1:1:500time (k) =k*ts;rin (k) = in (k); The% input is (0.95,1.05) the random number of the kp=0.6;ki=0.001;kd=0.001 distribution; The p,i,d parameter of the% setting is U (k) =kp*x (1) +kd*x (2) +ki*x (3); %pid Controller%linear Model Linear models yout (k) =-den (2) *y_1-den (3) *y_2-den (4) *y_3+num (2) *u_1+num (3) *u_2+num (4) *u_3;error (k) =rin (k)-yout (k);%return of Parametersu_3=u_2;u_2=u_1;u_1=u (k); Y_3=y_2;y_2=y_1;y_1=yout (k); X (1) =error (k); %calculating Px (2) = (Error (k)-error_1)/ts; %calculating x (3) =x (3) +error (k) *ts; %calculating Ixi (k) =x (3); Error_1=error (k); Endfigure (1);p lot (Time,rin, ' B ', time,yout, ' R '); Xlabel (' Time (s) '); Ylabel (' rin,yout ');

  

The effect is good, but also very happy. Next time, do a self-tuning control system based on annealing

PID control of Gaussian distribution input in MATLAB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.