You are on page 1of 5

Matlab Code:

clc;
close all;
clear all;
a1=-3:3;
a2=-3:3;
for i=1:length(a2)
for j=1:length(a1)
A=[a1(j) a2(i)]
b=[1];
a=[1 a1(j) a2(i)];
c=zeros(1,2);
c=roots(a);
%% checking stability using schur-cohn method
a=[a1(j) a2(i)];
A(length(a),:)=a;
B(length(a),:)=fliplr(A(length(a),:));
K(length(a))=A(length(a),length(a));
for m=length(a)-1:-1:1
for n=length(a):-1:1

end

A(m,n)=(A(m+1,n)-K(m+1)*B(m+1,n))/(1-K(m+1)^2);
end
K(m)=A(m,m);
B(m,:)=fliplr(A(m,:));

if sum(abs(K)>1)>0
display('Unstable')
else
display('Stable');
end
%% marking the unstable and satble region
if(abs(c(1))>abs(c(2)))
k=abs(c(1));
l=abs(c(2));
else
k=abs(c(2));
l=abs(c(1));
end
display(K),display(k) %test

[columns rows] = meshgrid(-k-3:.01:k+3, -k-3:.01:k+3);


x= 0;
y = 0;
r = k;

if k>1
C1 = (round((rows - y).^2 ...
+ (columns - x).^2) == 1);
C2=(((rows - y).^2 ...
+ (columns - x).^2) >= r.^2);
C=C1+C2;
figure
imagesc(C);
colormap([0 1 0; 1 0 0]);
elseif k<=1
C1 = (floor((rows - y).^2 ...
+ (columns - x).^2) == 1);
C2=(((rows - y).^2 ...
+ (columns - x).^2) <= r.^2);
C=C1+C2;
figure
imagesc(C);
colormap([0 1 0; 1 0 0]);
end

end
end

Simulation :
(a1=-2 ,a2=0)&(a1=-1,a2=0)

(a1=1 ,a2=0)&(a1=2,a2=0):

(a1= .2,a2=.4):

You might also like