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

4 vues (au cours des 30 derniers jours)
Li Mun Ng
Li Mun Ng le 24 Sep 2019
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?

Réponses (1)

Subhadeep Koley
Subhadeep Koley le 31 Oct 2019
Modifié(e) : Subhadeep Koley le 31 Oct 2019
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!

Catégories

En savoir plus sur Fuzzy Logic Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by