RW Criterion Matlab Design Classnotes
RW Criterion Matlab Design Classnotes
%polynomials
n=[1]; d=[1 1 2 23];
Sysg=tf(n,d)
CLG=feedback(Sysg,[1])
poles(CLG)
𝑠 + 2𝑠 + 4𝑠 + 𝑘
0 < K < 20
RW-Lab-LectureNotes Page 1
plot(p(:,8),'x')
RW-Lab-LectureNotes Page 2
RW-Lab-LectureNotes Page 3
%Obtaining the aK stability region
a=[.1:.01:3.0];K=[20:1:120];
x=0*K; y=0*K; %to initialize the plotting vector (correct length)
n=length(K);m=length(a);
For i=1:n
For j=1:m
q=[1, 8, 17,K(i)+10, K(i)*a(j)];%each polynomial for the change of a & K
p=roots(q);
If max(real(p))>0,x(i)=K(i); y(i)=a(j-1);%for a given value of K determine a instability
Break; end
End
End
Plot(x,y), grid on, xlabel('K'),ylabel('a')
RW-Lab-LectureNotes Page 4
%Using a ramp Response
%start K=70 and a=1
t=[0:.01:16];u=t; %unit ramp
ngc=[1 1]; dgc=[1 1]; %a value n
sysgc=tf(ngc,dgc) %tf k=70 a=1
ng=[70];dg=[1 7 10 0];
sysg=tf(ng,dg)
sysa=series(sysgc,sysg)
sysG=feedback(sysa,[1])
y=lsim(sysG,u,t),
Plot(t,y,t,u.'--'), grid on;
xlabel('Time (s)'), ylabel('y(t)')
RW-Lab-LectureNotes Page 5
RW-Lab-LectureNotes Page 6
RW-Lab-LectureNotes Page 7
RW-Lab-LectureNotes Page 8
RW-Lab-LectureNotes Page 9
RW-Lab-LectureNotes Page 10
RW-Lab-LectureNotes Page 11