Adding noise to a PID signal

조회 수: 36 (최근 30일)
Nathan Ross
Nathan Ross 2022년 3월 18일
댓글: Sam Chak 2022년 3월 31일
Hi everyone, As the title says I have created a PID system, and am attempting to add random noise over the created signal, but am unsure how to create the noise in this instance as it is not a normal function. Any advice or tips on how do add noise in this domain is greatly appreiated. Code is shown below
clear % housekeeping
clc % housekeeping
num= [1] % num of transfer function
denom= [1 3 1] % denom of transfer function
gp= tf(num, denom) % transfer function
h= [1] ; % feedback
m_nocontroller=feedback(gp, h)
step(m_nocontroller)
hold on
kp=3;
ki=0;
kd=0;
gc=pid(kp, ki, kd)
mc=feedback(gc*gp, h)
step(mc)
grid on

답변 (1개)

Pat Gipper
Pat Gipper 2022년 3월 31일
Hi Nathan,
You can use the lsim command to get a general response of your controller. I think you want to see the response when there is noise added to the input command. The code snippet below will do this for you.
t=(0:.001:7)';% time vector
u=ones(size(t));% input vector
n=randn(size(t));% Normal distributed samples
y=lsim(mc,u+n,t);% System response to step + random noise
% Plot PID response to unit step with added noise
figure;plot(t,y);grid
Sometimes the noise is added in at a separate point in the system as a disturbance. For example, it might be a disturbance that is added after the PID controller. But you would need to re-create your system object with the second input to do this.
  댓글 수: 1
Sam Chak
Sam Chak 2022년 3월 31일
Thank you for the suggested solution to plot the noise-contaminated system output.
Since the output measurement is contaminated by noise, it will affect the PID controller output signal as well. Would you advise @Nathan Ross on how to plot the noise-contaminated PID control signal for a linear system as well?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by