in gaussian membership function from what value of signal the mean is subtracted?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
for i=1:n
A(i)=exp(-0.5*((x-c(i))./s(i)).^2);
end
where
x=sin(2*pi*t)
t=1:.3:10
n=length(x)
c=.4*ones(1,n) %mean
s=.4*ones(1,n) %variance
for each iteration what is the value of x from which mean is subtracted ?
Accepted Answer
Image Analyst
on 19 Dec 2013
Edited: Image Analyst
on 19 Dec 2013
It's all values of x. x is an array and if you don't specify an element, like x(i), then it does ALL elements. So it won't work because you'd be trying to stuff a whole vector into a single element of A. I'd say that you probably want x(i) instead of x.
Try it this vectorized way instead:
t=1:.3:10
x=sin(2*pi*t)
n=length(x)
c=.4*ones(1,n) %mean
s=.4*ones(1,n) %variance
A = exp(-0.5*((x-c)./s).^2)
6 Comments
pinak parida
on 25 Dec 2013
i realize that i have difficulties in viewing an algorithm in matrix or vectorized form, that is why i can not write a correct code in MATLAB.
can you provide some explanatory document with algorithms and programs that enhance my idea about how to proceed and write program in MATLAB.
Image Analyst
on 25 Dec 2013
Edited: Image Analyst
on 25 Dec 2013
The t line creates an array of all the t without the need to create the array element by element in a for loop. Then the x lines creates an array of x for every t in the array without using the for loop. Finally A creates an array of that formula for every possible x without using a for loop. I left the semicolons off so you could see what it does.
pinak parida
on 31 Dec 2013
Edited: pinak parida
on 2 Jan 2014
%fuzzy logic inference system
clc
clear
close all
% desired signal creation
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
figure(1)
plot(u)
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
%let us consider 3 input i.e 'x1,x2,x3';so m=j=3
%again each input is fed to 'n=i'number of MF,
%input signal creation
m=3;
n=length(yd);
for j=1:1:m
for t=1:1000
if t<250
x(t)=sin(pi*t/25);
elseif t<500 && t>249
x(t)=1;
elseif t<750 && t>499
x(t)=-1;
else
x(t)=0.3*sin(pi*t/25)+0.1*sin(pi*t/32)+0.6*sin(pi*t/10);
end
end
end
figure(1)
plot(x)
U=.1; %learning parameter
c=0.4*ones(m,n); %mean of guassian mf
s=0.5*ones(m,n); %variance of gaussian mf
%defining weight
W =0.4*ones(1,n); %weight of LF
% generating MF
q=30;
while(q)
for j=1:1:m
for i=1:1:n
%gaussian MF---- A(m,n)=exp(-((x(m)-c(m,n)/s(m,n))^2)
A(j,:)=exp(-0.5*((x(j)-c(j,:))./s(j,:)).^2);
end
end
for i=1:1:n
for j=1:1:m
f(i)=min(A(:,i)); %f(i)=min(A(j,i))
y(i)=sum(W(i)*(x(j))); %y(i)=sumation j=1 to j=m (w(i)*x(j))
end
%output of fuzzy system
%p=sumation i=1 to i=n (f(i)*y(i))/sumation i=1 to i=n (f(i))
p(i)=sum(f(i)*y(i))/(sum(f(i)));
e(i)=yd(i)-p(i); %error
for j=1:1:m
% updation rule
W(i) = W(i)+U*e(i)*x(j);
c(j,:) = c(j,:) + 0.5*e(i)*exp(-(x(j)-c(j,:)./s(j,:)).^2).* (x(j)-c(j,:)./(s(j,:).^2));
s(j,:) = s(j,:) + 0.5*e(i)*exp(-(x(j)-c(j,:)./s(j,:)).^2).*(x(j)-c(j,:)).^2./((s(j,:)).^3);
end
end
%calculation of mse
p1=(sum(p)/(31));
MSE((31)-q)=sqrt(sum(e.^2)/sum((yd-p1).^2));
q=q-1;
end
figure(3)
plot(yd)
hold on
plot(p,'r')
hold on
plot(e,'g')
figure(4)
plot(MSE,'k','linewidth',2)
sir, i wrote this program for neuro-fuzzy system and got output. the error is decreasing with increase in iteration. BUT with changing the updation equation of mean(c)and variance(s) the output and mse does not change. so i cann't conclude whether program is CORRECT or NOT.
Image Analyst
on 2 Jan 2014
I'm not that familiar with fuzzy algorithms so I wouldn't know if it's correct or not.
pinak parida
on 5 Jan 2014
sir , do you know anyone i can contact?
thankyou
Image Analyst
on 5 Jan 2014
There is a fuzzy logic toolbox, though I don't recall seeing a lot of fuzzy questions here. You can try rephrasing your question, listing "Fuzzy Logic Toolbox" in the product list, and making the title something like "Need help with Fuzzy Logic program" to see if any fuzzy experts here answer you. The Mathworks tech support line won't help with algorithm development, only things like errors, syntax, and other purely MATLAB-related stuff like that.
More Answers (0)
Categories
Find more on Fuzzy Logic Toolbox in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)