EngHussein
Newbie level 3
- Joined
- Feb 5, 2013
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,301
Dear all
I have wrote the below code in matlab function - simulink in order to act as a Fuzzy controller, that code has been simplified in order to be converted to VHDL code to be run on Quartus - Altera KIT
I have faced several essential errors can anyone help by this..... thanks in advance for your coopration
here is the code
I have wrote the below code in matlab function - simulink in order to act as a Fuzzy controller, that code has been simplified in order to be converted to VHDL code to be run on Quartus - Altera KIT
I have faced several essential errors can anyone help by this..... thanks in advance for your coopration
here is the code
Code:
function y = fcn(u)
%#codegen
sf = 9;
CnN=-1*sf;
CnP=1*sf;
Cz=0;
cj= 0.5*sf;
cen=(abs(CnN-u))/cj;
cep=(abs(CnP-u))/cj;
cez=(abs(Cz-u))/cj;
%-----------------------------------%
if (cen >1)
men=0;
else
men=1-cen;
end;
if(cep >1)
mep=0;
else
mep=1-cep;
end;
if(cez >1)
mez=0;
else
mez=1-cez;
end
%-------------------------------------%
if (men<=0)
men = 0;
end
if (mez<=0)
mez = 0;
end
if (mep<=0)
mep = 0;
end
%----------------------
sca=(men+mez+mep);
nca11=CnN*men;
nca21=CnP*mep;
nca31=Cz*mez;
nnca= (nca11+nca21+nca31);
if sca==0;
y=0;
else
y=1*((nnca/sca)/sf);
end;
end
Last edited by a moderator: