First, write out the expression for the closed-loop function to obtain the polynomial of the denominator. Calculate the roots of the denominator polynomial; if all roots have real parts less than 0, the system is stable; otherwise, the system is unstable.
% Root-finding method to analyze system stability
% roots(p);
% pole(G);
% eig(G);
% tf();
% feedback();
% ss2zp();
%%%%%%%%%%%
clear all;
clc;
close all;
%%%%%%%%%%%%%
%%%%%%%%%%%%%
% Example 1, constant denominator polynomial: den1;
% s^5 + 2*s^4 + 3*s^3 + 4*s^2 – 5*s + 6 = 0
den1 = [1 2 3 4 -5 6];
p1 = roots(den1);
% p1(4) = 0.5618 + 0.6444i
% p1(5) = 0.5618 – 0.6444i
a = find(real(p1) >= 0);
if length(a) > 0
disp(‘System 1 is unstable.’);
else
disp(‘System 1 is stable.’);
end
disp(p1);
%%%%%%%%%%%%%
% Example 2, constant transfer function:
clear all;
num1 = [1 2 3];
den1 = [2 5 8 11];
G1 = tf(num1, den1);
p1 = pole(G1);
a = find(real(p1) >= 0);
if length(a) > 0
disp(‘System 2 is unstable.’);
else
disp(‘System 2 is stable.’);
end
disp(p1);
%%%%%%%%%%%%%
% Example 3, forward path and feedback path transfer functions:
clear all;
% Forward path transfer function
num1 = [1 4];
den1 = [1 3 5 7];
G1 = tf(num1, den1);
% Feedback path transfer function
num2 = [2 3];
den2 = [4 5 6 7];
G2 = tf(num2, den2);
G3 = feedback(G1, G2);
p1 = eig(G3);
a = find(real(p1) >= 0);
if length(a) > 0
disp(‘System 3 is unstable.’);
else
disp(‘System 3 is stable.’);
end
disp(p1);
%%%%%%%%%%%%%
% Example 4, constant transfer function:
clear all;
A = [1.6 -2.1 -1.3;
2.2 -3.8 -1.4
1.1 -1.5 -1.6];
B = [4; 5; 6];
C = [0 0 1];
D = 0;
[z1, p1, k1] = ss2zp(A, B, C, D);
a = find(real(p1) >= 0);
if length(a) > 0
disp(‘System 4 is unstable.’);
else
disp(‘System 4 is stable.’);
end
disp(p1);
%%%%%%%%%%%%%%%
disp(‘End.’)