problem with RLS estimation of TS model
Show older comments
salutations
im trying to get the recursive least squares estimation of TS fuzzy model consequents. i have developed the following code but unfortunately and to my amazement, its generating mtimes error. unable to troubleshoot. the error appears at statement w=w'+K*epsilon, using teh option of element by elememt multiplication has also been proved useless as its giving times error:( can anyone resolve the issue.
plz verify my selection of regressor and parameter matrices (a and w respectively)
{
function [ output_args ] = RLS_Function( input_args )
%RLS_FUNCTION Summary of this function goes here
% Detailed explanation goes here
x1=input_args(1);
x2=input_args(1);
% number_of_rules=5;
number_of_rules_mine=25;
%---------------------------------------------
%--------Initializing weights-----------------
%---------------------------------------------
persistent w;
if isempty(w)
w=ones(3,number_of_rules_mine)*0.1;
end
% w=ones(1,number_of_rules)*0.1;
%---------------------------------------------
%-----------Initializing P---------------------
%---------------------------------------------
Pt=eye(25); % P(t)
%---------------------------------------------
%-----------Identification Process------------
%---------------------------------------------
%
% for number_of_epochs=1:100
% %
% for sample=1:101
no_x1_mf=5;
no_x2_mf=5;
%---------------------------------------------
%-----------Fuzzification --------------------
%---------------------------------------------
PossIx1=Fuzzification_x(x1);
PossIx2=Fuzzification_x(x2);
%---------------------------------------------
%--------Calculating Strength of the rule-----
%---------------------------------------------
% count=1;
for i=1:3
for j=1:number_of_rules_mine
if i==1
a(i,j)=PossIx1(i); % dim(a) = 1 x 25
end
if i==2
a(i,j)=PossIx2(i); % dim(a) = 1 x 25
end
if i==3
a(i,j)=1; % dim(a) = 1 x 25
end
% a(count)=PossIx1(i); % dim(a) = 1 x 25
% count=count+1;
end
end
%count=total number of rules
%---------------------------------------------
%-----------Calculating K---------------------
%---------------------------------------------
num=Pt*a';
den=eye(3)+a*Pt*a';
K=num*inv(den);
%---------------------------------------------
%-----------Calculating P---------------------
%---------------------------------------------
Pt=Pt-K*a*Pt;
%---------------------------------------------
%------Calculating epsilon--------------------
%---------------------------------------------
epsilon=x1-a*w'; %since y=x
%---------------------------------------------
%------------Weight update--------------------
%---------------------------------------------
w=w'+K*epsilon;
output_args=a*w';
% end
% end
}
Answers (1)
first
on 29 Oct 2011
sorry i made some mistake in the code. since im dealing with TS fuzzy model of first order so the code should be as follows
{
function [ output_args ] = RLS_Function( input_args )
%RLS_FUNCTION Summary of this function goes here
% Detailed explanation goes here
x1=input_args(1);
x2=input_args(1);
number_of_rules=5;
%---------------------------------------------
%--------Initializing weights-----------------
%---------------------------------------------
persistent w;
if isempty(w)
w=ones(3,number_of_rules*number_of_rules)*0.1;
end
% w=ones(1,number_of_rules)*0.1;
%---------------------------------------------
%-----------Initializing P---------------------
%---------------------------------------------
Pt=eye(25); % P(t)
%---------------------------------------------
%-----------Identification Process------------
%---------------------------------------------
%
% for number_of_epochs=1:100
% %
% for sample=1:101
no_x1_mf=5;
no_x2_mf=5;
%---------------------------------------------
%-----------Fuzzification --------------------
%---------------------------------------------
PossIx1=Fuzzification_x(x1);
PossIx2=Fuzzification_x(x2);
%---------------------------------------------
%--------Calculating Strength of the rule-----
%---------------------------------------------
count=1;
for i=1:no_x1_mf
for j=1:no_x2_mf
a(count)=PossIx1(i)*PossIx2(j); % dim(a) = 1 x 25
% a(count)=PossIx1(i); % dim(a) = 1 x 25
count=count+1;
end
end
%count=total number of rules
%---------------------------------------------
%-----------Calculating K---------------------
%---------------------------------------------
num=Pt*a';
den=1+a*Pt*a';
K=num/den;
%---------------------------------------------
%-----------Calculating P---------------------
%---------------------------------------------
Pt=Pt-K*a*Pt;
%---------------------------------------------
%------Calculating epsilon--------------------
%---------------------------------------------
epsilon=x1-a*w'*[x2 x1 1]'; %since y=x
% epsilon=x1-a*w';
%---------------------------------------------
%------------Weight update--------------------
%---------------------------------------------
w=w'*[x2 x1 1]'+K*epsilon;
output_args=a*w';
end
}
Categories
Find more on Correlation Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!