All All: Adaptive Model Reference Controller Based On RLS Algorithm With Reference Signal R (T) 10 Cos (2 Pi n/50)
All All: Adaptive Model Reference Controller Based On RLS Algorithm With Reference Signal R (T) 10 Cos (2 Pi n/50)
signal r(t)=10*cos(2*pi*n/50)
close all;
clear all;
clc;
N=300; %interations
n=1:N+1; % time intravals
r=10*cos(2*pi*n/50) ;% system reference signal
u=[0 0]; %initial inputs
uf=[0 0]; %initial filter inputs
ym=[0 0 0]; %initial reference outputs
y=[0 0 0]; %initial output
yf=[0 0 0]; % initial filter outputs
th_0=[1 0.4 -2.5316 1.4493]; % system parameters
th=[0 0 th_0(1) ;0 0 th_0(2);0 0 th_0(3);0 0 th_0(4)];
p=0.7*eye(4); % Identity matrix
for t=3:N-1
r0h(t+1)=th_0(1);
r1h(t+1)=th_0(2);
s0h(t+1)=th_0(3);
s1h(t+1)=th_0(4);
ym(t+1)=0.4177*r(t)+1.0316*ym(t)-0.4493*ym(t-1);
uf(t)=1/r0h(t+1)*(-r1h(t+1)*uf(t-1)-s0h(t+1)*yf(t)-s1h(t+1)*yf(t-1)+ym(t+1));
phi=[uf(t); uf(t-1);yf(t); yf(t-1);];
u(t)=uf(t)-1.0316*uf(t-1)+0.4493*uf(t-2);
y(t+1)=-1.5*y(t)+y(t-1)+u(t)+0.4*u(t-1);
yf(t+1)=y(t+1)+1.0316*yf(t)-0.4493*yf(t-1);
e(t+1)=y(t+1)-ym(t+1);
p=p-p*phi*phi'*p/(1+phi'*p*phi);
th(:,t+1)=th(:,t)+p*phi*e(t+1);
end
figure;
subplot(311);plot(th');title('controller parameters'),grid on;
grid on;
subplot(312);plot(e,'k');title('error e(k)'),grid on;
grid on;