how to draw steady-state error versus time graphs in matlab

To draw steady-state error versus time graphs in matlab, first, we need to generate a step input and apply it to the system. After applying the step input, we can simulate the response of the system using step() function.

Once the response of the system is simulated, we can calculate the steady-state error using the following formula:

ess = 1 - lim(s -> 0) G(s)H(s) / [1 + lim(s -> 0) G(s)H(s)]

where G(s) is the transfer function of the system and H(s) is the transfer function of the feedback loop.

The steady-state error can be plotted against time using the following code:

main.m
% Define the transfer function of the system 
G = tf([1], [1 2 5]);

% Define the transfer function of the feedback loop 
H = tf([1], [1]);

% Generate a step input 
t = 0:0.1:10;
u = ones(size(t));

% Simulate the response of the system 
[y, t] = step(G * H, t);

% Calculate the steady-state error 
ess = 1 - dcgain(G * H) / (1 + dcgain(G * H));

% Plot the steady-state error versus time
plot(t, ess * ones(size(t)), 'r--', t, y, 'b', 'LineWidth', 1.5);
xlabel('Time');
ylabel('Output');
title('Steady-State Error versus Time');
legend('Steady-State Error', 'System Response');
581 chars
23 lines

This code will generate a plot of the steady-state error versus time, along with the response of the system to the step input.

related categories

gistlibby LogSnag