how to find steady state error of an arbitrary signal

조회 수: 76 (최근 30일)
Ali Esmaeilpour
Ali Esmaeilpour 2019년 10월 1일
댓글: Ali Esmaeilpour 2019년 10월 1일
I got a code which results a "y" signal as output and I wanted to find its steady state error. I gave an arbitrary input signal "W" as shown in my code
my code is as follows:
clc;
clear;
close all;
%% Initialization
T0=0 ;
Tf=20 ;
Ts=0.1 ;
t=T0:Ts:Tf ;
system=tf([1 1],[1 1 2]); % system=(s+1)/(s^2+s+2)
system_dis=c2d(system,Ts) ;
system_dis_ss=ss(system_dis) ;
Am=system_dis_ss.a;
Bm=system_dis_ss.b;
Cm=system_dis_ss.c;
n=size(Am,1); % Number of state variables
Om=zeros(1,n);
A=[Am,Om';Cm*Am,1];
B=[Bm ;Cm*Bm];
C=[Om 1];
p=10; % Prediction horizon
m=5; % Control horizon
Q=1;
R=1;
F=zeros(p,n+1);
for i=1:p
F(i,:)=C*A^i;
end
PHI=zeros(p,m);
for i=1:p
for j=1:i
PHI(i,j)=C*A^(i-j)*B;
end
end
PHI=PHI(:,1:m);
%% Main Loop
Nt=numel(t);
%W=ones(Nt,1); % Reference signal
W=[ones(floor(Nt/4),1);2*ones(floor(Nt/4),1);-ones(floor(Nt/4),1);zeros(floor(Nt/4+1),1)];
y=zeros(Nt,1);
du=zeros(Nt,1);
x=zeros(n+1,Nt); % (System state)+integral ===> n+1
Fval=zeros(Nt,1);
for i=1:Nt-1
FreeResponse=F*x(:,i);
dU=(PHI'*Q*PHI+R)\(PHI'*Q*(W(i)-FreeResponse)) ;
du(i)=dU(1); % Receding horizon
x(:,i+1)=A*x(:,i)+B*du(i); % State variable update
y(i+1)=C*x(:,i+1); % Output update
end
%%
ynew=y(21:101);
Wnew=W(21:101);
Mp=100*(max(ynew)/ynew(81,1))
figure(1)
plot(t(21:101),y(21:101),'linewidth',2)
  댓글 수: 2
Aquatris
Aquatris 2019년 10월 1일
Steady state error is when the difference between the output and the desired value of the output when the output does not change anymore.
Numerically you can apply an input to your system, run you system long enough for output of the system to settle at a constant value. Then compare the output value to the desired value to obtain the steady state error.
Alternatively, since you have your system, you can use stepinfo function to obtain the answer.
However your system seems to be an unstable one, which makes no sense to define steady state error.
Ali Esmaeilpour
Ali Esmaeilpour 2019년 10월 1일
my system is stable. plz give me a code I don't want definition of ess.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by