Plz tell why the output is not following the desired ?

2 Ansichten (letzte 30 Tage)
pinak parida
pinak parida am 25 Jul. 2013
clc
close all
clear all
%type1 network fuzzy
yd1=-.1;
yd0=-.07;
u3=0;
u2=0;
u1=0;
u0=0;
for t=1:1000
if t<250
u(t)=sin(pi*t/25);
elseif t<500 && t>249
u(t)=1;
elseif t<750 && t>499
u(t)=-1;
else
u(t)=0.3*sin(pi*t/25)+0.1*sin(pi*t/32)+0.6*sin(pi*t/10);
end
end
yd(1)=0.72*yd0+0.025*yd1*u1+0.01*(u2)^2+0.2*u3;
yd(2)=0.72*yd(1)+0.025*yd0*u0+0.01*(u1)^2+0.2*u2;
yd(3)=0.72*yd(2)+0.025*yd(1)*u(1)+0.01*(u0)^2+0.2*u1;
yd(4)=0.72*yd(3)+0.025*yd(2)*u(2)+0.01*(u(1))^2+0.2*u0;
for t=4:999
yd(t+1)=0.72*yd(t)+0.025*yd(t-1)*u(t-1)+0.01*(u(t-2))^2+0.2*u(t-3);
end
figure
plot(yd);
m=5; %number of input
U=.4; %learning rate
n=length(yd);
c=0.4*ones(m,n); %mean of Gaussian mf
s=0.4*ones(m,n); %variance of Gaussian mf
%defining weight
W = 0.1*ones(m);
for i=1:m
for j=1:n
A(:,i)=exp(-0.5*((u(i)-c(:,i))./s(:,i)).^2); % n no. of mf
R(i)=min(A(:,i)); %fuzzy rule
y(i)=sum(u(i)*W(:,i));
end
for j=1:n
B(i)=((sum(R(i)*y(i))/sum(R(i)))); %output of fuzzy nural structure
e(j) = yd(i)-B(i); %erroe
end
end
%update rule for weight,mean ,variance
for i=1:m
for j=1:n
W(:,i) = W(:,i)+m*e(j)*u(i);
c(:,i) = c(:,i) + (0.5*e(j)*(exp(-(u(i)-c(:,i)./s(:,i)).^2)));
s(:,i) = s(:,i) + (0.5*e(j)*(exp(-(u(i)-c(:,i)./s(:,i)).^2)));
end
MSE(n+1-i) = sum(e.^2);
end
figure;
plot(u,'r') %output plot
figure;
plot(e,'k') %error plot
figure
plot(MSE) % meansquare error plot
e(i)^2
DESCRIPTION This is fuzzy neural network having n input. and by fuzzyfication and rule and defuzzyfication output is obtained. which is compared with desired and error is calculated. and also the weight, mean and variance is updated.
But problem is the out put is not following the desired. PLZ help.
  4 Kommentare
pinak parida
pinak parida am 27 Jul. 2013
inside fuuzy block
pinak parida
pinak parida am 29 Aug. 2013
x=[1 6]; mu=.004; yd=[15 21]; m=2; n=3; c=[1 2 3;4 5 6] s=[1 2 3;4 5 6] w=[1 2; 3 4; 5 6] %3x2 %A=[1 2 3; 4 5 6] %2x3 epoc=100; while(epoc) for j=1:m for i=1:n A(j,:)=exp(-0.5*((x(j)-c(j,:))./s(j,:)).^2); R(i)=min(A(:,i)); %1x3 y=w*x'; end p=y'*R'; Q=sum(p); V=sum®; B(j)=Q/V e(j)=yd(j)-B(j);
end w=w+mu*x*e'; c=c+mu*x*e'; s=s+mu*x*e'; epoc=epoc-1; plot(B) end
hi friend, what is the problem here that i am not getting the desired that is nearly equal to [15 21]. instead i get both the value same at last step what ever may be the epoc. plz help i could not find out it.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Richard McCulloch
Richard McCulloch am 27 Jul. 2013
I would check your indices. Try this:
clc
close all
clear all
%type1 network fuzzy
yd1=-.1;
yd0=-.07;
u3=0;
u2=0;
u1=0;
u0=0;
for t=1:1000
if t<250
u(t)=sin(pi*t/25);
elseif t<500 && t>249
u(t)=1;
elseif t<750 && t>499
u(t)=-1;
else
u(t)=0.3*sin(pi*t/25)+0.1*sin(pi*t/32)+0.6*sin(pi*t/10);
end
end
yd(1)=0.72*yd0+0.025*yd1*u1+0.01*(u2)^2+0.2*u3;
yd(2)=0.72*yd(1)+0.025*yd0*u0+0.01*(u1)^2+0.2*u2;
yd(3)=0.72*yd(2)+0.025*yd(1)*u(1)+0.01*(u0)^2+0.2*u1;
yd(4)=0.72*yd(3)+0.025*yd(2)*u(2)+0.01*(u(1))^2+0.2*u0;
for t=4:999
yd(t+1)=0.72*yd(t)+0.025*yd(t-1)*u(t-1)+0.01*(u(t-2))^2+0.2*u(t-3);
end
figure
plot(yd);
title('yd')
m=5; %number of input
U=.4; %learning rate
n=length(yd);
c=0.4*ones(m,n); %mean of Gaussian mf
s=0.4*ones(m,n); %variance of Gaussian mf
%defining weight
W = 0.1*ones(m,1);
for i=1:m
for j=1:n
A(:,j)=exp(-0.5*((u(j)-c(:,i))./s(:,i)).^2); % n no. of mf
R(j)=min(A(:,i)); %fuzzy rule
y(j)=sum(u(j)*W(i));
end
for j=1:n
B(j)=((sum(R.*y)./sum(R))); %output of fuzzy nural structure
e(j) = yd(j)-B(j); %erroe
end
end
%update rule for weight,mean ,variance
for i=1:m
for j=1:n
W(i) = W(i)+m*e(j)*u(i);
c(:,i) = c(:,i) + (0.5*e(j)*(exp(-(u(i)-c(:,i)./s(:,i)).^2)));
s(:,i) = s(:,i) + (0.5*e(j)*(exp(-(u(i)-c(:,i)./s(:,i)).^2)));
end
MSE(n+1-i) = sum(e.^2);
end
figure;
plot(u,'r') %output plot
title('u')
figure;
plot(e,'k') %error plot
title('error')
figure
plot(MSE) % meansquare error plot
title('MSE')
figure
plot(B)
title('B')
e(i)^2
It kind of works, but it gives B a value of zero, so your error ends up being yd. If you can reverse that you're set, but try checking the indices, especially in the "j" loops.
  3 Kommentare
pinak parida
pinak parida am 30 Jul. 2013
CAN'T. can anyone detect the fault of solve.
Jan
Jan am 30 Jul. 2013
When you omit the useless clear all you can set some breakpoints in the code and use the debugger to see, what's going on inside.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Fuzzy Logic in Simulink finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by