Computing Integral Errors : Mathematica vs Matlab Simulink
​Authors: Housam Binous and Ahmed Bellagi

ConsidertheclosedloopshowninFigure11.8in[1]​​​​
​​​​where
G
p
=
2
3s+1
,
G
v
=
1
2s+1
,
G
m
=
1
s+1
,
K
m
=1,and
G
c
=
K
c
+
1
5s
(PIcontroller).Here,weassumethatD=0andYsp=1/s.
Reference :​
[1] D . E . Seborg, T . F . Edgar, D . A . Mellichamp, and F . J . Doyle III, Process Dynamics and Control, 4 th ed ., Hoboken, NJ : John Wiley & Sons, Inc ., 2017.
In[]:=
Kc=q;
In[]:=
Gp=2/(3s+1);Gv=1/(2s+1);Gm=1/(s+1);Gc=Kc+1/(5s);
In[]:=
GcGvGp/(1+GcGvGpGm)//FullSimplify
Out[]=
2(1+s)(1+5qs)
2+5s(2q+(1+s)(1+2s)(1+3s))

Time-domain response

In[]:=
y[q_?NumericQ]:=InverseLaplaceTransform1s
2(1+s)(1+5qs)
2+5s(2q+(1+s)(1+2s)(1+3s))
,s,t;(*q=Kc*)
In[]:=
ym[q_?NumericQ]:=InverseLaplaceTransform1s
2(1+s)(1+5qs)
2+5s(2q+(1+s)(1+2s)(1+3s))
Gm,s,t;
mresp=ym[1];(*mesuredresponseforKc=1*)
resp=y[1];(*responseforKc=1*)
Thethreeintegralerrors(alltruncatedatt=50inthecalculationshownhere)aredefinedby:​​​​IAE=
∞
∫
0
e(t)dt=4.697(theintegraloftheabsolutevalueoftheerror),​​​​ISE=
∞
∫
0
2
(e(t))
dt=2.628(theintegralofthesquarederror),​​​​and​​​​ITAE=
∞
∫
0
te(t)dt=24.715(theintegralofthetime-weightedabsoluteerror).
In[]:=
ISE=NIntegrate[(1-mresp)^2,{t,0,50},Method->{Automatic,"SymbolicProcessing"->False}]
Out[]=
2.62866
In[]:=
IAE=Quiet@NIntegrate[Abs[1-mresp],{t,0,50},Method->{Automatic,"SymbolicProcessing"->False}]
Out[]=
4.69659
In[]:=
ITAE=Quiet@NIntegrate[tAbs[1-mresp],{t,0,50},Method->{Automatic,"SymbolicProcessing"->False}]
Out[]=
24.715
Response versus time
In[]:=
p=Plot[resp,{t,0,200},PlotRange->{{0,50},{0,1.4}},PlotStyle->Dashed,Frame->True,GridLines->Automatic,FrameLabel->{Style["t",16,Italic],Style["response",16,Italic]},AspectRatio->1]
Out[]=
img=
;(*fromSimulink*)
In[]:=
Show[p,ImageSize->400{1,1},Prolog->{Raster[ImageData[img,DataReversed->True],{Scaled[{0.0,0.0}],Scaled[{1,1.}]}]},FrameLabel->{Style["t",16,Italic],Style["y",16,Italic]}]
Out[]=
Error versus time
img=
;(*fromSimulink*)
In[]:=
p=Plot[1-mresp,{t,0,200},PlotRange->{{0,50},{-0.4,1.0}},PlotStyle->Dashed,Frame->True,GridLines->Automatic,FrameLabel->{Style["t",16,Italic],Style["error",16,Italic]},AspectRatio->1]
Out[]=