Why this error occurs?

조회 수: 15 (최근 30일)
Anila Yasmeen
Anila Yasmeen 2017년 10월 4일
편집: Jan 2017년 10월 4일
% Fuzzy rules and its implementation
close all; clear; clc
fuzzy_Mamdani = newfis('FL power switching.fis'); %%%%%%%%%%%%%%%Step1: Fuzzification of the input and output variables%%%%%% %% Input variables fuzzy_Mamdani.input(1).name = 'Load power'; fuzzy_Mamdani.input(1).range = [0 1]; fuzzy_Mamdani.input(1).mf(1).name = 'Low'; fuzzy_Mamdani.input(1).mf(1).type = 'trimf'; fuzzy_Mamdani.input(1).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.input(1).mf(2).name = 'Medium'; fuzzy_Mamdani.input(1).mf(2).type = 'trimf'; fuzzy_Mamdani.input(1).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.input(1).mf(3).name = 'High'; fuzzy_Mamdani.input(1).mf(3).type = 'trimf'; fuzzy_Mamdani.input(1).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.input(2).name = 'Solar power'; fuzzy_Mamdani.input(2).range = [0 1]; fuzzy_Mamdani.input(2).mf(1).name = 'Low'; fuzzy_Mamdani.input(2).mf(1).type = 'trimf'; fuzzy_Mamdani.input(2).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.input(2).mf(2).name = 'Medium'; fuzzy_Mamdani.input(2).mf(2).type = 'trimf'; fuzzy_Mamdani.input(2).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.input(2).mf(3).name = 'High'; fuzzy_Mamdani.input(2).mf(3).type = 'trimf'; fuzzy_Mamdani.input(2).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.input(3).name = 'Wind power'; fuzzy_Mamdani.input(3).range = [0 1]; fuzzy_Mamdani.input(3).mf(1).name = 'Low'; fuzzy_Mamdani.input(3).mf(1).type = 'trimf'; fuzzy_Mamdani.input(3).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.input(3).mf(2).name = 'Medium'; fuzzy_Mxrfdddddddddddddddddddddddddccccsx .amdani.input(3).mf(2).type = 'trimf'; fuzzy_Mamdani.input(3).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.input(3).mf(3).name = 'High'; fuzzy_Mamdani.input(3).mf(3).type = 'trimf'; fuzzy_Mamdani.input(3).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.input(4).name = 'Storage power'; fuzzy_Mamdani.input(4).range = [0 1]; fuzzy_Mamdani.input(4).mf(1).name = 'Low'; fuzzy_Mamdani.input(4).mf(1).type = 'trimf'; fuzzy_Mamdani.input(4).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.input(4).mf(2).name = 'Medium'; fuzzy_Mamdani.input(4).mf(2).type = 'trimf'; fuzzy_Mamdani.input(4).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.input(4).mf(3).name = 'High'; fuzzy_Mamdani.input(4).mf(3).type = 'trimf'; fuzzy_Mamdani.input(4).mf(3).params = [0.5 0.7 1];
% outputs
fuzzy_Mamdani.output(1).name = 'G2L'; fuzzy_Mamdani.output(1).range = [0 1]; fuzzy_Mamdani.output(1).mf(1).name = 'Low'; fuzzy_Mamdani.output(1).mf(1).type = 'trimf'; fuzzy_Mamdani.output(1).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(1).mf(2).name = 'Medium'; fuzzy_Mamdani.output(1).mf(2).type = 'trimf'; fuzzy_Mamdani.output(1).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(1).mf(3).name = 'High'; fuzzy_Mamdani.output(1).mf(3).type = 'trimf'; fuzzy_Mamdani.output(1).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.output(2).name = 'PV2L'; fuzzy_Mamdani.output(2).range = [0 1]; fuzzy_Mamdani.output(2).mf(1).name = 'Low'; fuzzy_Mamdani.output(2).mf(1).type = 'trimf'; fuzzy_Mamdani.output(2).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(2).mf(2).name = 'Medium'; fuzzy_Mamdani.output(2).mf(2).type = 'trimf'; fuzzy_Mamdani.output(2).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(2).mf(3).name = 'High'; fuzzy_Mamdani.output(2).mf(3).type = 'trimf'; fuzzy_Mamdani.output(2).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.output(3).name = 'W2L'; fuzzy_Mamdani.output(3).range = [0 1]; fuzzy_Mamdani.output(3).mf(1).name = 'Low'; fuzzy_Mamdani.output(3).mf(1).type = 'trimf'; fuzzy_Mamdani.output(3).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(3).mf(2).name = 'Medium'; fuzzy_Mamdani.output(3).mf(2).type = 'trimf'; fuzzy_Mamdani.output(3).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(3).mf(3).name = 'High'; fuzzy_Mamdani.output(3).mf(3).type = 'trimf'; fuzzy_Mamdani.output(3).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.output(4).name = 'BAT2L'; fuzzy_Mamdani.output(4).range = [0 1]; fuzzy_Mamdani.output(4).mf(1).name = 'Low'; fuzzy_Mamdani.output(4).mf(1).type = 'trimf'; fuzzy_Mamdani.output(4).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(4).mf(2).name = 'Medium'; fuzzy_Mamdani.output(4).mf(2).type = 'trimf'; fuzzy_Mamdani.output(4).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(4).mf(3).name = 'High'; fuzzy_Mamdani.output(4).mf(3).type = 'trimf'; fuzzy_Mamdani.output(4).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.output(5).name = 'PV2BAT'; fuzzy_Mamdani.output(5).range = [0 1]; fuzzy_Mamdani.output(5).mf(1).name = 'Low'; fuzzy_Mamdani.output(5).mf(1).type = 'trimf'; fuzzy_Mamdani.output(5).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(5).mf(2).name = 'Medium'; fuzzy_Mamdani.output(5).mf(2).type = 'trimf'; fuzzy_Mamdani.output(5).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(5).mf(3).name = 'High'; fuzzy_Mamdani.output(5).mf(3).type = 'trimf'; fuzzy_Mamdani.output(5).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.output(6).name = 'W2BAT'; fuzzy_Mamdani.output(6).range = [0 1]; fuzzy_Mamdani.output(6).mf(1).name = 'Low'; fuzzy_Mamdani.output(6).mf(1).type = 'trimf'; fuzzy_Mamdani.output(6).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(6).mf(2).name = 'Medium'; fuzzy_Mamdani.output(6).mf(2).type = 'trimf'; fuzzy_Mamdani.output(6).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(6).mf(3).name = 'High'; fuzzy_Mamdani.output(6).mf(3).type = 'trimf'; fuzzy_Mamdani.output(6).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.output(7).name = 'G2BAT'; fuzzy_Mamdani.output(7).range = [0 1]; fuzzy_Mamdani.output(7).mf(1).name = 'Low'; fuzzy_Mamdani.output(7).mf(1).type = 'trimf'; fuzzy_Mamdani.output(7).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(7).mf(2).name = 'Medium'; fuzzy_Mamdani.output(7).mf(2).type = 'trimf'; fuzzy_Mamdani.output(7).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(7).mf(3).name = 'High'; fuzzy_Mamdani.output(7).mf(3).type = 'trimf'; fuzzy_Mamdani.output(7).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.output(8).name = 'PV2ELEC'; fuzzy_Mamdani.output(8).range = [0 1]; fuzzy_Mamdani.output(8).mf(1).name = 'Low'; fuzzy_Mamdani.output(8).mf(1).type = 'trimf'; fuzzy_Mamdani.output(8).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(8).mf(2).name = 'Medium'; fuzzy_Mamdani.output(8).mf(2).type = 'trimf'; fuzzy_Mamdani.output(8).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(8).mf(3).name = 'High'; fuzzy_Mamdani.output(8).mf(3).type = 'trimf'; fuzzy_Mamdani.output(8).mf(3).params = [0.5 0.7 1];
fuzzy_Mamdani.output(9).name = 'W2ELEC'; fuzzy_Mamdani.output(9).range = [0 1]; fuzzy_Mamdani.output(9).mf(1).name = 'Low'; fuzzy_Mamdani.output(9).mf(1).type = 'trimf'; fuzzy_Mamdani.output(9).mf(1).params = [0 0.2 0.4]; fuzzy_Mamdani.output(9).mf(2).name = 'Medium'; fuzzy_Mamdani.output(9).mf(2).type = 'trimf'; fuzzy_Mamdani.output(9).mf(2).params = [0.2 0.5 0.7]; fuzzy_Mamdani.output(9).mf(3).name = 'High'; fuzzy_Mamdani.output(9).mf(3).type = 'trimf'; fuzzy_Mamdani.output(9).mf(3).params = [0.5 0.7 1]; %%%%%Rules evaluation and inference system%%%%%%%%%%%
cold_Mamdani.rule(1).antecedent = [1 1 1 1]; cold_Mamdani.rule(1).consequent = [1 1 1 1 1 1 3 1 1]; cold_Mamdani.rule(1).weight = 1; cold_Mamdani.rule(1).connection = 1;
cold_Mamdani.rule(2).antecedent = [1 1 1 2]; cold_Mamdani.rule(2).consequent = [1 1 1 2 1 1 1 1 1]; cold_Mamdani.rule(2).weight = 1; cold_Mamdani.rule(2).connection = 1;
cold_Mamdani.rule(3).antecedent = [1 1 1 3]; cold_Mamdani.rule(3).consequent = [1 1 1 3 1 1 1 1 1]; cold_Mamdani.rule(3).weight = 1; cold_Mamdani.rule(3).connection = 1;
cold_Mamdani.rule(4).antecedent = [1 1 2 1]; cold_Mamdani.rule(4).consequent = [1 1 2 1 1 2 1 1 1]; cold_Mamdani.rule(4).weight = 1; cold_Mamdani.rule(4).connection = 1;
cold_Mamdani.rule(5).antecedent = [1 1 2 2]; cold_Mamdani.rule(5).consequent = [1 1 2 1 1 1 1 1 1]; cold_Mamdani.rule(5).weight = 1; cold_Mamdani.rule(5).connection = 1;
cold_Mamdani.rule(6).antecedent = [1 1 2 3]; cold_Mamdani.rule(6).consequent = [1 1 2 1 1 1 1 1 1]; cold_Mamdani.rule(6).weight = 1; cold_Mamdani.rule(6).connection = 1;
cold_Mamdani.rule(7).antecedent = [1 1 3 1]; cold_Mamdani.rule(7).consequent = [1 1 3 1 1 2 1 1 1]; cold_Mamdani.rule(7).weight = 1; cold_Mamdani.rule(7).connection = 1;
cold_Mamdani.rule(8).antecedent = [1 1 3 2]; cold_Mamdani.rule(8).consequent = [1 1 3 1 1 2 3 1 1]; cold_Mamdani.rule(8).weight = 1; cold_Mamdani.rule(8).connection = 1;
cold_Mamdani.rule(9).antecedent = [1 1 3 3]; cold_Mamdani.rule(9).consequent = [1 1 3 1 1 1 1 1 2]; cold_Mamdani.rule(9).weight = 1; cold_Mamdani.rule(9).connection = 1;
cold_Mamdani.rule(10).antecedent = [1 2 1 1]; cold_Mamdani.rule(10).consequent = [1 2 1 1 2 1 1 1 1]; cold_Mamdani.rule(10).weight = 1; cold_Mamdani.rule(10).connection = 1;
cold_Mamdani.rule(11).antecedent = [1 2 1 2]; cold_Mamdani.rule(11).consequent = [1 2 1 1 2 1 1 1 1]; cold_Mamdani.rule(11).weight = 1; cold_Mamdani.rule(11).connection = 1;
cold_Mamdani.rule(12).antecedent = [1 2 1 3]; cold_Mamdani.rule(12).consequent = [1 2 1 1 1 1 1 2 1]; cold_Mamdani.rule(12).weight = 1; cold_Mamdani.rule(12).connection = 1;
cold_Mamdani.rule(13).antecedent = [1 2 2 1]; cold_Mamdani.rule(13).consequent = [1 2 1 1 1 2 1 2 1]; cold_Mamdani.rule(13).weight = 1; cold_Mamdani.rule(13).connection = 1;
cold_Mamdani.rule(14).antecedent = [1 2 2 2]; cold_Mamdani.rule(14).consequent = [1 2 1 1 1 2 1 1 1]; cold_Mamdani.rule(14).weight = 1; cold_Mamdani.rule(14).connection = 1;
cold_Mamdani.rule(15).antecedent = [1 2 2 3]; cold_Mamdani.rule(15).consequent = [1 2 1 1 1 1 1 1 2]; cold_Mamdani.rule(15).weight = 1; cold_Mamdani.rule(15).connection = 1; plotfis(fuzzy_Mamdani);
error Index exceeds matrix dimensions.
Error in discfis (line 69) mfType=deblank(mfTypeList(mfIndex2,:));
Error in plotfis (line 57) [xi,yi,xo,yo,r]=discfis(fis,181);
Error in fuzzy_rules (line 243) plotfis(fuzzy_Mamdani);

답변 (1개)

Jan
Jan 2017년 10월 4일
편집: Jan 2017년 10월 4일
This is an extremely ugly code. It is impossible to debug this pile of redundant blocks. It looks like you lost your patients also during the editing:
fuzzy_Mxrfdddddddddddddddddddddddddccccsx .amdani.input(3).mf(2).type = 'trimf';
??? Sure you want to do this? In a clean and clear code this would have caught your attention immediately.
Prefer to use loops, store the data in MAT files, matrices or cell strings, such that the structure get clear. Then debugging or maintaining the code will not be so hard.
Anyway, the error message is clear:
error Index exceeds matrix dimensions.
Error in discfis (line 69) mfType=deblank(mfTypeList(mfIndex2,:));
Obviously the array mfTypeList is shorter than the indices stored in mfIndex2. You can check this easily using the debugger. Type this in the command window
dbstop if error
Then run again. If Matlab stops at the error, check this:
size(mfTypeList)
max(mfIndex2)
Are you aware, that you have posted a bunch of unreadable code, but it does not even contain the failing line. Therefore I cannot even guess the relation between the shown code and the error.

카테고리

Help CenterFile Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by