필터 지우기
필터 지우기

How to convert the fuzzy output to text? (MATLAB App Designer 2017b)

조회 수: 4 (최근 30일)
Li Mun Ng
Li Mun Ng 2019년 9월 24일
편집: Subhadeep Koley 2019년 10월 31일
Good day all.
I am making an application using MATLAB App Designer and fuzzy logic is applied in it in order to calculate the result. The output of fuzzy logic is a number. However, I wish to change it to text. I used four Edit Filed (Numeric) as inputs and one Edit Field (Text) as the ouput since I intend to display a text instead of number.
fis = readfis('FIS');
i1=app.FirstInputEditField.Value; % inputs of fis
i2=app.SecondInputEditField.Value;
i3=app.ThirdInputEditField.Value;
i4=app.FourthInputEditField.Value;
inputs=[i1 i2 i3 i4];
output = evalfis(inputs,fis);
set(app.ResultEditField.Text,'String',value); % to convert from fuzzy number to text
if value == 0.9
set(app.ResultEditField.Text,'String'good,);
else if value == 0.4
set(app.ResultEditField.Text,'String',average);
else value == 0.1
set(app.ResultEditField.Text,'String',normal);
end
app.ResultEditField.Value=output; % the final output
However, when I tried running the app, it shows the following error.
Error using FIS
Error: File: FIS.mlapp Line: 57 Column: 5
Illegal use of reserved keyword "methods".
The methods and fucntions are having red lines.
Does anyone know where did I go wrong?

답변 (1개)

Subhadeep Koley
Subhadeep Koley 2019년 10월 31일
편집: Subhadeep Koley 2019년 10월 31일
It seems there is a space between else and if in your code, also we should not provide a logical expression for the else case. These are probably the reason why the methods and functionsare having red underlines.
However, use code below to achieve what you want. (Also, refer to the attached .zip file)
Go to "Fuzzy Button > callbacks > AddButtonPushedFcn callback" and paste the following code
fis = readfis('tipper'); % Read your fis here
i1=app.IP1EditField.Value; % Replace "IP1.EditField" with your field name
i2=app.IP2EditField.Value; % Do the same for all the input & output fields
inputs=[i1 i2];
output = evalfis(inputs,fis); % Evaluate fis, here the output is of type double
% Use appropriate logical expression and linguistic variables as per your need
if output >= 7
app.OPEditField.Value = 'Excellent'; % Note that “OPEditField” is a Edit Field(Text) component
elseif output >= 6
app.OPEditField.Value = 'Good';
else
app.OPEditField.Value = 'Average';
end
Hope this helps!

카테고리

Help CenterFile Exchange에서 Fuzzy Logic Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by