How do I clear the errors in my code?There are lot of errors.

This is my code and it is not working.

9 Comments

Sir, thank you for replying :) i have attached a file .
Dear Gauti, attachment is still missing
where do i check if the attachment is there are not?
If it is attached then you can see it attached and then we can download it. For example, in this comment I have attached an empty file which you can see and download. In the same way your attachment should be visible
"A lot of errors" is not possible in Matlab. The processing stops at the first error, so there cannot be more than one error. So please explain, why you think, that there are many errors. What messages do you see where?
Unless he means syntax errors, which are highlighted by a red line at the offending code and in the right margin.
showfis('SUGENO1')
Attempt to reference field of non-structure array.
Error in showfis (line 42) NumRules=length(fis.rule);
>>
Error using evalfismex Invalid FIS. PARAMS field of linear output MF has incorrect length.
Error in evalfis (line 84) [output,IRR,ORR,ARR] = evalfismex(input, fis, numofpoints);
Error in ruleview (line 451) [v,irr,orr,arr]=evalfis(inputVector,fis, numPts);
Error in ruleview (line 313) ruleview #update
Error in fisgui (line 102) eval([tag '(fis);']);
Error while evaluating uimenu Callback

Sign in to comment.

Answers (1)

We don't really need your code if you look at this link and do what it shows you: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/

13 Comments

Thank You very much. The problem is am very new to Matlab... I am finding it very difficult to start over.. I watch videos one by one.. pause and do as it says for the fundamentals.. Writing code and debugging for a give problem.. i am not getting it. How do i start over?
The first line of your code is this:
a = newfis('gauti','sugeno');
I don't have newfis(), so I can't run your code. Why don't you tell us what your error message are? Copy and paste all the red text. For example, does it say
Undefined function 'newfis' for input arguments of type 'char'.
Error in test (line 1)
a = newfis('gauti','sugeno');
like it does for me? If so, you haven' defined newfis().
> fuzzy >> SUGENO1
SUGENO1 =
name: 'SUGENO1'
type: 'sugeno'
andMethod: 'prod'
orMethod: 'probor'
defuzzMethod: 'wtaver'
impMethod: 'prod'
aggMethod: 'sum'
input: [1x1 struct]
output: [1x1 struct]
rule: [1x8 struct]
>> evalfis('SUGENO1') Need at least two inputs
ans =
[]
how do i give input to the system?
where do i exactly give the inputs? i have used fuzzy logic toolbox, sugeno type inferene system.
You still did not answer the question of Image Analyst. What is the error message that you get while running gauti.m.
Unfortunately I don't have the fuzzy logic toolbox, but what I get from the help is that you need at least 2 inputs for evalfis. An input matrix, and a FIS structure. I assume SUGENO1 is your FIS structure, so what you still need is to define the input matrix.
Let's say we call the input matrix ' inputmat '. Then you could call evalfis like this:
evalfis(inputmat, SUGENO1)
a = newfis('gauti','sugeno');
a.input(1).name='linearvelocity'; a.input(1).range=[-1.3 1.3];
a.input(1).mf(1).name='NS'; a.input(1).mf(1).type='trapmf'; a.input(1).mf(1).params=[-1.3 -1 -0.25 -0.08];
a.input(1).mf(2).name='VNS'; a.input(1).mf(2).type='trimf'; a.input(1).mf(2).params=[-0.25 -0.08 0.08];
a.input(1).mf(3).name='ZE'; a.input(1).mf(3).type='trimf'; a.input(1).mf(3).params=[-0.08 0 0.08];
a.input(1).mf(4).name='VPS'; a.input(1).mf(4).type='trimf'; a.input(1).mf(4).params=[0 0.08 0.25];
a.input(1).mf(5).name='PS'; a.input(1).mf(5).type='trimf'; a.input(1).mf(5).params=[0.08 0.25 0.4];
a.input(1).mf(6).name='PM'; a.input(1).mf(6).type='trimf'; a.input(1).mf(6).params=[0.25 0.4 0.6];
a.input(1).mf(7).name='PB'; a.input(1).mf(7).type='trimf'; a.input(1).mf(7).params=[0.4 0.6 0.8];
a.input(1).mf(8).name='VPB'; a.input(1).mf(8).type='trapmf'; a.input(1).mf(8).params=[0.6 0.8 1 1.3];
%ouput membershipfunction
a.output(1).name='lin_velocity'; a.output(1).range=[-41 250];
a.output(1).mf(1).name='NS'; a.output(1).mf(1).type='trimf'; a.output(1).mf(1).params=[-40.001 -40 -39];
a.output(1).mf(2).name='VNS'; a.output(1).mf(2).type='trimf'; a.output(1).mf(2).params=[-31 -30 -29];
a.output(1).mf(3).name='ZE'; a.output(1).mf(3).type='trimf'; a.output(1).mf(3).params=[-1 0 1];
a.output(1).mf(4).name='VPS'; a.output(1).mf(4).type='trimf'; a.output(1).mf(4).params=[49 50 51];
a.output(1).mf(5).name='PS'; a.output(1).mf(5).type='trimf'; a.output(1).mf(5).params=[99 100 101];
a.output(1).mf(6).name='PM'; a.output(1).mf(6).type='trimf'; a.output(1).mf(6).params=[146 150 151];
a.output(1).mf(7).name='PB'; a.output(1).mf(7).type='trimf'; a.output(1).mf(7).params=[199 200 201];
a.output(1).mf(8).name='VPB'; a.output(1).mf(8).type='trimf'; a.output(1).mf(8).params=[248 249 250];
%rule list
a.rule(1).antecedent=[1]; a.rule(1).consequent=[1]; a.rule(1).weight=1; a.rule(1).connection=1;
a.rule(2).antecedent=[2]; a.rule(2).consequent=[2]; a.rule(2).weight=1; a.rule(2).connection=1;
a.rule(3).antecedent=[3]; a.rule(3).consequent=[3]; a.rule(3).weight=1; a.rule(3).connection=1;
a.rule(4).antecedent=[4]; a.rule(4).consequent=[4]; a.rule(4).weight=1; a.rule(4).connection=1;
a.rule(5).antecedent=[5]; a.rule(5).consequent=[5]; a.rule(5).weight=1; a.rule(5).connection=1;
a.rule(6).antecedent=[6]; a.rule(6).consequent=[6]; a.rule(6).weight=1; a.rule(6).connection=1;
a.rule(7).antecedent=[7]; a.rule(7).consequent=[7]; a.rule(7).weight=1; a.rule(7).connection=1;
a.rule(8).antecedent=[8]; a.rule(8).consequent=[8]; a.rule(8).weight=1; a.rule(8).connection=1;
plotfis('gauti'); writefis(a,'gauti')
sir, this is my code from command line for sugeno fuzzy inference system.
when i run that code, an empty figure is appearing.
evalfis(inputmat, 'SUGENO1')
Undefined function or variable 'inputmat'.
How did you define inputmat?
Sir , i got the output but not understanding the logic. can u explain? fismat = readfis('SUGENO1')
fismat =
name: 'sugeno'
type: 'sugeno'
andMethod: 'prod'
orMethod: 'probor'
defuzzMethod: 'wtaver'
impMethod: 'prod'
aggMethod: 'sum'
input: [1x1 struct]
output: [1x1 struct]
rule: [1x2 struct]
out = evalfis([2 2],fismat,2)
out =
0.1092
0.1092
We don't know what evalfis() or newfis() are. All we know is that they require two inputs. And you need to pass in two inputs that match the type of input they are expecting. If you are trying to call those routines I would think that you would know what they want and what they return. Otherwise, why would you call them?

Sign in to comment.

Categories

Find more on Fuzzy Logic Toolbox in Help Center and File Exchange

Asked:

on 13 Oct 2013

Commented:

on 16 Oct 2013

Community Treasure Hunt

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

Start Hunting!