I am trying to use MATLAB to calculate a steady-state error. I have found a weblink that gives code for finding the steady-state error, but when I use that code I get a value of the steady-error greater than 1. In my understanding, a steady-state error should be less than 1, because formula of steady-state error in case of step input = 1/(1+k)

The code:


When I try to incorporate the above code into my code to get the steady-state error:

clc;clear all;close all
%defining parameters values
%defining numerator & denominator of system1 (1/js+b)
den=[j b]
% creating transfer function for system 1
%Applying block diagram reduction and simplification techniques
%Creating a positive feedback system from above two systems sys1 and sys2
%Introducing the effect of disturbance input 
%Calculating step response & extracting amplitude & time matrices
%Plotting  values of amplitude matrix extracted from  step resposne
%Calculating length(total number of elements) for timing matrix 
%Finding value of last element of amplitude matrix
%That is also value of steady state speed
SP=1 % set point incase of step input

I am trying to simulate a block diagram from a book, Modern Control Systems. I am also attaching a snapshot of that block diagram.

There are two block diagrams in the snapshot, one is for an open-loop control system and the other is for a closed-loop control system.

I am considering and trying to write code for an open-loop system.

Update: Note: Plot has been added in response to comment

enter image description here

enter image description here

  • \$\begingroup\$ Can you post a time versus value plot of the signal? \$\endgroup\$
    – AJN
    Commented Sep 30, 2021 at 15:45
  • \$\begingroup\$ If the set point is positive, then clearly the steady state error is more than one since the response is negative value. \$\endgroup\$
    – AJN
    Commented Oct 1, 2021 at 8:30
  • \$\begingroup\$ Good day. I don't have an answer to the question but wanted to ask the name/title of the book where are figures 4.7 and 4.9 from. Could you say, please? \$\endgroup\$
    – Agasha
    Commented Nov 21, 2021 at 10:17
  • \$\begingroup\$ @Agasha - Hi, I didn't write the question, but I believe I recognise the figures as being from the book "Modern Control Systems" by Richard C. Dorf and Robert H. Bishop. Hopefully LECS can confirm that. \$\endgroup\$
    – SamGibson
    Commented Nov 21, 2021 at 15:47

2 Answers 2




The output of the closed loop system is negated before it is supplied to the step function.

So even though the output of the original system a is going to 0.66 (steady state error 0.33), due to the negation of the output in OL, the calculation returns 1.66 > 1.

What is the reason / logic for doing OL = -1 * a ?


There is one logical error also.

[y,t]=step(OL)         % SP is NOT the input given here!
SP=1                   % the set point has NO effect on y !
sserror=abs(SP-y(end)) % this calculation is hence invalid

Since the step function is called before setting the setpoint SP, the calculation SP - y(end) is invalid since SP was not the input actually supplied to the system.

The code in the link you provided in the question has the correct order of operations.

SP=5; %input value, if you put 1 then is the same as step(sys)
[y,t]=step(SP*sys); %get the response of the system to a step with amplitude SP
sserror=abs(SP-y(end)) %get the steady state error

enter image description here

I think you should be treating at the system like this, and analyze the system this way, taking \$T_d(s)\$ as your main input. With such a diagram, the definition for sys2 and sys1 changes, as you might notice. It becomes the formula below.

$$sys2=\frac{K_m(K_tK_b+K_a)}{R_a}$$ $$sys1=\frac{-1}{Js+b}$$

Rewriting the code according to this might yield a correct result.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.