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