Main Content

comparefis

Plot simulated output of fuzzy systems for comparison

Since R2024b

    Description

    comparefis(fis,x) evaluates each fuzzy inference system (FIS) in fis using the input value sin x and shows the simulated output values in a stacked plot.

    example

    comparefis(fis,x,Name=Value) configures the comparison plot using one or more name-value arguments.

    example

    Examples

    collapse all

    Load a Mamdani fuzzy inference system.

    fisM = readfis("tipper");

    Create a Sugeno version of the same fuzzy system.

    fisS = convertToSugeno(fisM);
    fisS.Name = "tipperSugeno";

    Create random reference input values.

    x = 10*rand(100,2);

    Compare the outputs of the two fuzzy systems.

    comparefis([fisM fisS],x)

    Figure contains an object of type stackedplot.

    The output of the Sugeno system closely matches the output of the Mamdani system.

    Evaluate tuned FIS performance from Tune Fuzzy Inference System at the Command Line.

    Load the training data and extract a set of validation data.

    [data,name] = loadGasData;
    X = data(:,1:6);
    Y = data(:,7);
    vldX = X(2:2:end,:);
    vldY = Y(2:2:end,:);

    Load the trained FIS objects, including an intermediate FIS with learned rules and a final FIS with tuned membership function parameters.

    tunedfis = load("tunedfismpgprediction.mat");
    fisLearnedRules = tunedfis.fisout1;
    fisLearnedRules.Name = "LearnedRules";
    fisTunedMFs = tunedfis.fisout;
    fisTunedMFs.Name = "TunedMFs";

    Evaluate the FIS objects and compare their outputs to the validation data.

    fis = [fisLearnedRules, fisTunedMFs];
    comparefis(fis,vldX,OutputData=vldY)

    Figure contains an object of type stackedplot.

    View the error plot and root-mean-squared-error (RMSE) for both FIS objects.

    comparefis(fis,vldX, ...
        OutputData=vldY, ...
        ShowError=true)

    Figure contains an object of type stackedplot.

    Input Arguments

    collapse all

    Fuzzy inference systems to evaluate, specified as one of the following FIS objects or an array of such objects. All the FIS object must have the same number of inputs and outputs and each FIS object must have a unique name.

    • mamfis object — Mamdani fuzzy inference system

    • sugfis object — Sugeno fuzzy inference system

    • mamfistype2 object — Type-2 Mamdani fuzzy inference system

    • sugfistype2 object — Type-2 Sugeno fuzzy inference system

    • fistree object — Tree of interconnected fuzzy inference systems.

    If you specify a fistree object in fis, all the fuzzy systems in fis must be fistree objects.

    Input values, specified as an M-by-NX array, where M is the number of reference data points and NX is the number of inputs in fis.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: MergeInputs=false plots each input variable in its own axes.

    Reference output values, specified as an M-by-NY array, where M is the number of reference data points and NY is the number of outputs in fis.

    Option to display the plot legend, specified as a logical value.

    • true — Display the legend.

    • false — Do not display the legend.

    Option to plot the output error, specified as a logical value.

    • true — Plot the output error.

    • false — Do not plot the output error.

    Option to plot all inputs on the same axes, specified as a logical value.

    • true — Plot all inputs on the same axes.

    • false — Plot each input in a separate axes.

    Option to plot all outputs on the same axes, specified as a logical value.

    • true — Plot all outputs on the same axes.

    • false — Plot each output in a separate axes.

    Option to plot all errors on the same axes, specified as a logical value.

    • true — Plot all errors on the same axes.

    • false — Plot each error in a separate axes.

    Input variables to plot, specified as a vector of positive indices. To plot all input variables, set SelectedInputs to "all". To suppress the input-signal plot, set SelectedInputs to "[]".

    Output variables to plot, specified as a vector of positive indices. To plot all output variables, set SelectedOutputs to "all".

    FISs to plot, specified as a vector of positive indices. To plot the simulation results for all FISs, set SelectedFIS to "all".

    Number of sample points for output defuzzification when , specified as an integer greater than 1.

    Dependencies

    comparefis ignores this property when evaluating a Sugeno FIS.

    Alternative Functionality

    App

    You can interactively compare FIS outputs using the Fuzzy Logic Designer app. For more information, see Analyze Fuzzy System Using Fuzzy Logic Designer.

    Version History

    Introduced in R2024b