From: <lm...@us...> - 2012-08-24 16:13:17
|
Revision: 10909 http://octave.svn.sourceforge.net/octave/?rev=10909&view=rev Author: lmarkov Date: 2012-08-24 16:13:07 +0000 (Fri, 24 Aug 2012) Log Message: ----------- M inst/getfis.m M inst/psigmf.m M inst/smf.m M inst/rmvar.m M inst/partition_entropy.m M inst/trapmf.m M inst/bounded_difference.m M inst/newfis.m M inst/pimf.m M inst/zmf.m M inst/hamacher_sum.m M inst/setfis.m M inst/plotmf.m M inst/rmmf.m M inst/einstein_sum.m M inst/gustafson_kessel_demo_1.m M inst/gustafson_kessel_demo_2.m M inst/defuzz.m M inst/gbellmf.m M inst/gensurf.m M inst/algebraic_product.m M inst/xie_beni_index.m M inst/evalmf.m M inst/partition_coeff.m M inst/gustafson_kessel.m M inst/sugeno_tip_demo.m M inst/trimf.m M inst/cubic_approx_demo.m M inst/showfis.m M inst/heart_disease_demo_1.m M inst/heart_disease_demo_2.m M inst/mamdani_tip_demo.m M inst/gauss2mf.m M inst/drastic_product.m M inst/fcm_demo_1.m M inst/evalfis.m M inst/fcm_demo_2.m M inst/linear_tip_demo.m M inst/writefis.m M inst/algebraic_sum.m M inst/investment_portfolio_demo.m M inst/addvar.m M inst/bounded_sum.m M inst/gaussmf.m M inst/fcm.m M inst/sigmf.m M inst/hamacher_product.m M inst/showrule.m M inst/dsigmf.m M inst/addmf.m M inst/drastic_sum.m M inst/readfis.m M inst/einstein_product.m M inst/addrule.m Modified Paths: -------------- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_product.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_difference.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/defuzz.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_product.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/dsigmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_product.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm_demo_1.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm_demo_2.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gauss2mf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gaussmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gbellmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gustafson_kessel.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gustafson_kessel_demo_1.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gustafson_kessel_demo_2.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_product.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_disease_demo_1.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_disease_demo_2.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/investment_portfolio_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear_tip_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/mamdani_tip_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/newfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/partition_coeff.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/partition_entropy.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/pimf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/plotmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/psigmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/readfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/rmmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/rmvar.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/setfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/showfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/showrule.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/sigmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/smf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/sugeno_tip_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/trapmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/trimf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/writefis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/xie_beni_index.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/zmf.m Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -59,17 +59,18 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy membership-function membership +## Keywords: fuzzy-logic-toolkit fuzzy membership ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: addmf.m ## Note: The demo code is based on an assignment written by ## Dr. Bruce Segee (University of Maine Dept. of ECE). -## Last-Modified: 28 Oct 2011 +## Last-Modified: 18 Aug 2012 -function fis = addmf (fis, in_or_out, var_index, mf_name, mf_type, mf_params) +function fis = addmf (fis, in_or_out, var_index, mf_name, mf_type, ... + mf_params) - ## If the caller did not supply 6 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 6 argument values with the correct + ## types, print an error message and halt. if (nargin != 6) puts ("Type 'help addmf' for more information.\n"); @@ -92,9 +93,11 @@ error ("addmf's sixth argument must be a vector of parameters\n"); endif - ## Create a new membership function struct and update the FIS structure. + ## Create a new membership function struct and update the + ## FIS structure. - new_mf = struct ('name', mf_name, 'type', mf_type, 'params', mf_params); + new_mf = struct ('name', mf_name, 'type', mf_type, 'params', ... + mf_params); if (strcmp (tolower (in_or_out), 'input')) if (length (fis.input(var_index).mf) == 0) fis.input(var_index).mf = new_mf; @@ -119,9 +122,12 @@ %! ## Add two inputs and their membership functions. %! a = addvar (a, 'input', 'LDL-Level', [0 300]); %! a = addmf (a, 'input', 1, 'Low', 'trapmf', [-1 0 90 110]); -%! a = addmf (a, 'input', 1, 'Low-Borderline', 'trapmf', [90 110 120 140]); -%! a = addmf (a, 'input', 1, 'Borderline', 'trapmf', [120 140 150 170]); -%! a = addmf (a, 'input', 1, 'High-Borderline', 'trapmf', [150 170 180 200]); +%! a = addmf (a, 'input', 1, 'Low-Borderline', 'trapmf', ... +%! [90 110 120 140]); +%! a = addmf (a, 'input', 1, 'Borderline', 'trapmf', ... +%! [120 140 150 170]); +%! a = addmf (a, 'input', 1, 'High-Borderline', 'trapmf', ... +%! [150 170 180 200]); %! a = addmf (a, 'input', 1, 'High', 'trapmf', [180 200 300 301]); %! %! a = addvar (a, 'input', 'HDL-Level', [0 100]); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -84,12 +84,12 @@ ## Keywords: fuzzy-logic-toolkit fuzzy rule ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: addrule.m -## Last-Modified: 11 Nov 2011 +## Last-Modified: 18 Aug 2012 function fis = addrule (fis, rule_matrix) - ## If the caller did not supply 2 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 2 argument values with the correct + ## types, print an error message and halt. if (nargin != 2) puts ("Type 'help addrule' for more information.\n"); @@ -98,19 +98,20 @@ puts ("Type 'help addrule' for more information.\n"); error ("addrule's first argument must be an FIS structure\n"); elseif (!is_real_matrix (rule_matrix)) - puts ("Type 'help addrule' for more information.\n"); - error ("addrule's second argument must be a matrix of real numbers\n"); + puts ("Type 'help addrule' for more information. addrule's \n"); + error ("second argument must be a matrix of real numbers\n"); endif - ## For each row in the rule_matrix, create a new rule struct and update - ## the FIS structure. + ## For each row in the rule_matrix, create a new rule struct and + ## update the FIS structure. num_inputs = columns (fis.input); num_outputs = columns (fis.output); for i = 1 : rows (rule_matrix) antecedent = rule_matrix(i, 1 : num_inputs); - consequent = rule_matrix(i, (num_inputs+1) : (num_inputs+num_outputs)); + consequent = rule_matrix(i, ... + (num_inputs+1) : (num_inputs+num_outputs)); weight = rule_matrix(i, num_inputs + num_outputs + 1); connection = rule_matrix(i, num_inputs + num_outputs + 2); new_rules(i) = struct ('antecedent', antecedent, ... Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -46,12 +46,12 @@ ## Keywords: fuzzy-logic-toolkit fuzzy variable ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: addvar.m -## Last-Modified: 28 Oct 2011 +## Last-Modified: 18 Aug 2012 function fis = addvar (fis, in_or_out, var_name, var_range) - ## If the caller did not supply 4 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 4 argument values with the correct + ## types, print an error message and halt. if (nargin != 4) puts ("Type 'help addvar' for more information.\n"); @@ -74,7 +74,8 @@ ## Create a new variable struct and update the FIS input or output ## variable list. - new_variable = struct ('name', var_name, 'range', var_range, 'mf', []); + new_variable = struct ('name', var_name, 'range', var_range, ... + 'mf', []); if (strcmp (tolower (in_or_out), 'input')) if (length (fis.input) == 0) fis.input = new_variable; Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_product.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_product.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_product.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -37,14 +37,17 @@ ## Keywords: fuzzy-logic-toolkit fuzzy algebraic_product ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: algebraic_product.m -## Last-Modified: 12 Nov 2011 +## Last-Modified: 18 Aug 2012 function retval = algebraic_product (x, y = 0) if (!(isreal (x) && isreal (y))) + puts ("Arguments to algebraic_product must be real scalars "); + puts ("or matrices.\n"); puts ("Type 'help algebraic_product' for more information.\n"); - error ("algebraic_product requires real scalar or matrix arguments\n"); + error ("invalid arguments to function algebraic_product\n"); elseif (nargin == 2 && ... - (isscalar (x) || isscalar (y) || isequal (size (x), size (y)))) + (isscalar (x) || isscalar (y) || ... + isequal (size (x), size (y)))) retval = x .* y; elseif (nargin == 1 && ndims (x) <= 2) retval = prod (x); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_sum.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_sum.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -37,14 +37,15 @@ ## Keywords: fuzzy-logic-toolkit fuzzy algebraic_sum ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: algebraic_sum.m -## Last-Modified: 12 Nov 2011 +## Last-Modified: 18 Aug 2012 function retval = algebraic_sum (x, y = 0) if (!(isreal (x) && isreal (y))) puts ("Type 'help algebraic_sum' for more information.\n"); error ("algebraic_sum requires real scalar or matrix arguments\n"); elseif (nargin == 2 && ... - (isscalar (x) || isscalar (y) || isequal (size (x), size (y)))) + (isscalar (x) || isscalar (y) || ... + isequal (size (x), size (y)))) retval = x .+ y .- x .* y; elseif (nargin == 1 && isvector (x)) retval = algebraic_sum_of_vector (x); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_difference.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_difference.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_difference.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -38,14 +38,17 @@ ## Keywords: fuzzy-logic-toolkit fuzzy bounded_difference ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: bounded_difference.m -## Last-Modified: 12 Nov 2011 +## Last-Modified: 18 Aug 2012 function retval = bounded_difference (x, y = 0) if (!(isreal (x) && isreal (y))) + puts ("Function 'bounded_difference' requires real scalar "); + puts ("or matrix arguments.\n"); puts ("Type 'help bounded_difference' for more information.\n"); - error ("bounded_difference requires real scalar or matrix arguments\n"); + error ("invalid arguments to function bounded_difference\n"); elseif (nargin == 2 && ... - (isscalar (x) || isscalar (y) || isequal (size (x), size (y)))) + (isscalar (x) || isscalar (y) || ... + isequal (size (x), size (y)))) retval = max (0, (x .+ y - 1)); elseif (nargin == 1 && isvector (x)) retval = bounded_difference_of_vector (x); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_sum.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_sum.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -37,14 +37,15 @@ ## Keywords: fuzzy-logic-toolkit fuzzy bounded_sum ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: bounded_sum.m -## Last-Modified: 12 Nov 2011 +## Last-Modified: 18 Aug 2012 function retval = bounded_sum (x, y = 0) if (!(isreal (x) && isreal (y))) puts ("Type 'help bounded_sum' for more information.\n"); error ("bounded_sum requires real scalar or matrix arguments\n"); elseif (nargin == 2 && ... - (isscalar (x) || isscalar (y) || isequal (size (x), size (y)))) + (isscalar (x) || isscalar (y) || ... + isequal (size (x), size (y)))) retval = min (1, (x .+ y)); elseif (nargin == 1 && isvector (x)) retval = bounded_sum_of_vector (x); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/defuzz.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/defuzz.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/defuzz.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -53,14 +53,14 @@ ## Keywords: fuzzy-logic-toolkit fuzzy defuzzification ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: defuzz.m -## Last-Modified: 16 Jul 2011 +## Last-Modified: 18 Aug 2012 -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- function crisp_x = defuzz (x, y, defuzz_method) - ## If the caller did not supply 3 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 3 argument values with the correct + ## types, print an error message and halt. if (nargin != 3) puts ("Type 'help defuzz' for more information.\n"); @@ -70,31 +70,31 @@ error ("defuzz's first argument must be a valid domain\n"); elseif (!(isvector (y) && isreal (y) && length (x) == length (y))) puts ("Type 'help defuzz' for more information.\n"); - error ("defuzz's second argument must be a real number or vector\n"); + error ("defuzz's 2nd argument must be a real number or vector\n"); elseif (!is_string (defuzz_method)) puts ("Type 'help defuzz' for more information.\n"); error ("defuzz's third argument must be a string\n"); endif - ## Calculate and return the defuzzified (crisp_x) value using the method - ## specified by the argument defuzz_method. + ## Calculate and return the defuzzified (crisp_x) value using the + ## method specified by the argument defuzz_method. crisp_x = str2func (defuzz_method) (x, y); endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Usage: crisp_x = centroid (x, y) ## crisp_x = centroid ([x1 x2 ... xn], [y1 y2 ... yn]) ## ## For a given domain (x or [x1 x2 ... xn]) and corresponding y-values -## (y or [y1 y2 ... yn]), return the x-value of the centroid of the region -## described by the points (xi, yi). +## (y or [y1 y2 ... yn]), return the x-value of the centroid of the +## region described by the points (xi, yi). ## ## Both arguments are assumed to be reals or non-empty vectors of reals. -## In addition, x is assumed to be strictly increasing, and x and y are assumed -## to be of equal length. -##------------------------------------------------------------------------------ +## In addition, x is assumed to be strictly increasing, and x and y are +## assumed to be of equal length. +##---------------------------------------------------------------------- function crisp_x = centroid (x, y) @@ -102,7 +102,7 @@ endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Usage: crisp_x = bisector (x, y) ## crisp_x = bisector ([x1 x2 ... xn], [y1 y2 ... yn]) ## @@ -111,15 +111,15 @@ ## described by the points (xi, yi). ## ## Both arguments are assumed to be reals or non-empty vectors of reals. -## In addition, x is assumed to be strictly increasing, and x and y are assumed -## to be of equal length. -##------------------------------------------------------------------------------ +## In addition, x is assumed to be strictly increasing, and x and y are +## assumed to be of equal length. +##---------------------------------------------------------------------- function crisp_x = bisector (x, y) - ## Find the bisector using a binary search. To ensure that the function - ## terminates, add a counter to limit the iterations to the length of the - ## vectors x and y. + ## Find the bisector using a binary search. To ensure that the + ## function terminates, add a counter to limit the iterations to the + ## length of the vectors x and y. half_area = trapz (x, y) / 2; x_len = length (x); @@ -145,18 +145,19 @@ endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Usage: crisp_x = mom (x, y) ## crisp_x = mom ([x1 x2 ... xn], [y1 y2 ... yn]) ## ## For a given domain (x or [x1 x2 ... xn]) and corresponding y-values -## (y or [y1 y2 ... yn]), return the "Mean of Maximum"; that is, return the -## average of the x-values corresponding to the maximum y-value in y. +## (y or [y1 y2 ... yn]), return the "Mean of Maximum"; that is, return +## the average of the x-values corresponding to the maximum y-value +## in y. ## ## Both arguments are assumed to be reals or non-empty vectors of reals. -## In addition, x is assumed to be strictly increasing, and x and y are assumed -## to be of equal length. -##------------------------------------------------------------------------------ +## In addition, x is assumed to be strictly increasing, and x and y are +## assumed to be of equal length. +##---------------------------------------------------------------------- function crisp_x = mom (x, y) @@ -167,18 +168,19 @@ endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Usage: crisp_x = som (x, y) ## crisp_x = som ([x1 x2 ... xn], [y1 y2 ... yn]) ## ## For a given domain (x or [x1 x2 ... xn]) and corresponding y-values -## (y or [y1 y2 ... yn]), return the "Smallest of Maximum"; that is, return the -## smallest x-value corresponding to the maximum y-value in y. +## (y or [y1 y2 ... yn]), return the "Smallest of Maximum"; that is, +## return the smallest x-value corresponding to the maximum y-value +## in y. ## ## Both arguments are assumed to be reals or non-empty vectors of reals. -## In addition, x is assumed to be strictly increasing, and x and y are assumed -## to be of equal length. -##------------------------------------------------------------------------------ +## In addition, x is assumed to be strictly increasing, and x and y are +## assumed to be of equal length. +##---------------------------------------------------------------------- function crisp_x = som (x, y) @@ -189,18 +191,18 @@ endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Usage: crisp_x = lom (x, y) ## crisp_x = lom ([x1 x2 ... xn], [y1 y2 ... yn]) ## ## For a given domain (x or [x1 x2 ... xn]) and corresponding y-values -## (y or [y1 y2 ... yn]), return the "Largest of Maximum"; that is, return the -## largest x-value corresponding to the maximum y-value in y. +## (y or [y1 y2 ... yn]), return the "Largest of Maximum"; that is, +## return the largest x-value corresponding to the maximum y-value in y. ## ## Both arguments are assumed to be reals or non-empty vectors of reals. -## In addition, x is assumed to be strictly increasing, and x and y are assumed -## to be of equal length. -##------------------------------------------------------------------------------ +## In addition, x is assumed to be strictly increasing, and x and y are +## assumed to be of equal length. +##---------------------------------------------------------------------- function crisp_x = lom (x, y) @@ -211,17 +213,17 @@ endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Usage: retval = wtaver (values, weights) ## -## Return the weighted average of the values. The parameters are assumed to be -## equal-length vectors of real numbers. +## Return the weighted average of the values. The parameters are assumed +## to be equal-length vectors of real numbers. ## ## Examples: ## wtaver ([1 2 3 4], [1 1 1 1]) ==> 2.5 ## wtaver ([1 2 3 4], [1 2 3 4]) ==> 3 ## wtaver ([1 2 3 4], [0 0 1 1]) ==> 3.5 -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- function retval = wtaver (values, weights) @@ -229,17 +231,17 @@ endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Usage: retval = wtsum (values, weights) ## -## Return the weighted sum of the values. The parameters are assumed to be -## equal-length vectors of real numbers. +## Return the weighted sum of the values. The parameters are assumed to +## be equal-length vectors of real numbers. ## ## Examples: ## wtsum ([1 2 3 4], [1 1 1 1]) ==> 10 ## wtsum ([1 2 3 4], [1 2 3 4]) ==> 30 ## wtsum ([1 2 3 4], [0 0 1 1]) ==> 7 -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- function retval = wtsum (values, weights) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_product.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_product.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_product.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_sum.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_sum.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/dsigmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/dsigmf.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/dsigmf.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -65,15 +65,15 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy membership-function sigmoidal +## Keywords: fuzzy-logic-toolkit fuzzy membership sigmoidal ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: dsigmf.m -## Last-Modified: 28 Oct 2011 +## Last-Modified: 20 Aug 2012 function y = dsigmf (x, params) - ## If the caller did not supply 2 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 2 argument values with the correct + ## types, print an error message and halt. if (nargin != 2) puts ("Type 'help dsigmf' for more information.\n"); @@ -94,8 +94,9 @@ a2 = params(3); c2 = params(4); - y_val = @(x_val) max (0, min (1, 1 / (1 + exp (-a1 * (x_val - c1))) - ... - 1 / (1 + exp (-a2 * (x_val - c2))))); + y_val = @(x_val) max (0, ... + min (1, 1 / (1 + exp (-a1 * (x_val - c1))) - ... + 1 / (1 + exp (-a2 * (x_val - c2))))); y = arrayfun (y_val, x); endfunction Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_product.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_product.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_product.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_sum.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_sum.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -232,16 +232,17 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis +## Keywords: fuzzy-logic-toolkit fuzzy inference system fis ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: evalfis.m -## Last-Modified: 12 Nov 2011 +## Last-Modified: 20 Aug 2012 function [output, rule_input, rule_output, fuzzy_output] = ... evalfis (user_input, fis, num_points = 101) - ## If evalfis was called with an incorrect number of arguments, or the - ## arguments do not have the correct type, print an error message and halt. + ## If evalfis was called with an incorrect number of arguments, or + ## the arguments do not have the correct type, print an error message + ## and halt. if ((nargin != 2) && (nargin != 3)) puts ("Type 'help evalfis' for more information.\n"); @@ -251,7 +252,7 @@ error ("evalfis's second argument must be an FIS structure\n"); elseif (!is_input_matrix (user_input, fis)) puts ("Type 'help evalfis' for more information.\n"); - error ("evalfis's first argument must be a matrix of input values\n"); + error ("evalfis's 1st argument must be a matrix of input values\n"); elseif (!is_pos_int (num_points)) puts ("Type 'help evalfis' for more information.\n"); error ("evalfis's third argument must be a positive integer\n"); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -58,15 +58,15 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy membership-function evaluate +## Keywords: fuzzy-logic-toolkit fuzzy membership evaluate ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: evalmf.m -## Last-Modified: 13 Nov 2011 +## Last-Modified: 19 Aug 2012 function y = evalmf (x, params, mf_type, hedge = 0, not_flag = false) - ## If the caller did not supply 3 - 5 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 3 - 5 argument values with the correct + ## types, print an error message and halt. if ((nargin < 3) || (nargin > 5)) puts ("Type 'help evalmf' for more information.\n"); @@ -85,8 +85,8 @@ error ("evalmf's fifth argument must be a Boolean\n"); endif - ## Calculate and return the y values of the membership function on the - ## domain x. + ## Calculate and return the y values of the membership function on + ## the domain x. y = evalmf_private (x, params, mf_type, hedge, not_flag); @@ -97,7 +97,8 @@ %! params = [25 50 75]; %! mf_type = 'trimf'; %! y = evalmf(x, params, mf_type); -%! figure('NumberTitle', 'off', 'Name', "evalmf(0:100, [25 50 75], 'trimf')"); +%! figure('NumberTitle', 'off', 'Name', "evalmf(0:100, [25 50 75], ... +%! 'trimf')"); %! plot(x, y, 'LineWidth', 2) %! ylim([-0.1 1.1]); %! xlabel('Crisp Input Value', 'FontWeight', 'bold'); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2012 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -114,13 +114,14 @@ ## Keywords: fuzzy-logic-toolkit fuzzy partition clustering fcm ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: fcm.m -## Last-Modified: 10 July 2012 +## Last-Modified: 19 Aug 2012 function [cluster_centers, soft_partition, obj_fcn_history] = ... fcm (input_data, num_clusters, options = [2.0, 100, 1e-5, 1]) ## If fcm was called with an incorrect number of arguments, or the - ## arguments do not have the correct type, print an error message and halt. + ## arguments do not have the correct type, print an error message + ## and halt. if ((nargin != 2) && (nargin != 3)) puts ("Type 'help fcm' for more information.\n"); @@ -133,17 +134,19 @@ error ("fcm's second argument must be an integer greater than 1\n"); elseif (!(isreal (options) && isvector (options))) puts ("Type 'help fcm' for more information.\n"); - error ("fcm's third (optional) argument must be a vector of real numbers\n"); + error ("fcm's third argument must be a vector of real numbers\n"); endif - ## Assign options to the more readable variable names: m, max_iterations, - ## epsilon, and display_intermediate_results. If options are missing or - ## NaN (not a number), use the default values. + ## Assign options to the more readable variable names: m, + ## max_iterations, epsilon, and display_intermediate_results. + ## If options are missing or NaN (not a number), use the default + ## values. default_options = [2.0, 100, 1e-5, 1]; for i = 1 : 4 - if ((length (options) < i) || isna (options(i)) || isnan (options(i))) + if ((length (options) < i) || ... + isna (options(i)) || isnan (options(i))) options(i) = default_options(i); endif endfor @@ -160,16 +163,17 @@ display_intermediate_results); endfunction -##------------------------------------------------------------------------------ -## Note: This function (fcm_private) is an implementation of Figure 13.4 in -## Fuzzy Logic: Intelligence, Control and Information, by J. Yen and -## R. Langari, Prentice Hall, 1999, page 380 (International Edition) -## and Algorithm 4.1 in Fuzzy and Neural Control, by Robert Babuska, -## November 2009, p. 63. -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- +## Note: This function (fcm_private) is an implementation of Figure 13.4 +## in Fuzzy Logic: Intelligence, Control and Information, by +## J. Yen and R. Langari, Prentice Hall, 1999, page 380 +## (International Edition) and Algorithm 4.1 in Fuzzy and Neural +## Control, by Robert Babuska, November 2009, p. 63. +##---------------------------------------------------------------------- function [V, Mu, obj_fcn_history] = ... - fcm_private (X, k, m, max_iterations, epsilon, display_intermediate_results) + fcm_private (X, k, m, max_iterations, epsilon, ... + display_intermediate_results) ## Initialize the prototype and the calculation. V = fcm_init_prototype (X, k); @@ -182,23 +186,27 @@ n = rows (X); sqr_dist = square_distance_matrix (X, V); - ## Loop until the objective function is within tolerance or the maximum - ## number of iterations has been reached. - while (convergence_criterion > epsilon && ++iteration <= max_iterations) + ## Loop until the objective function is within tolerance or the + ## maximum number of iterations has been reached. + while (convergence_criterion > epsilon && ... + ++iteration <= max_iterations) V_previous = V; Mu = fcm_update_membership_fcn (V, X, m, k, n, sqr_dist); Mu_m = Mu .^ m; V = fcm_update_cluster_centers (Mu_m, X, k); sqr_dist = square_distance_matrix (X, V); - obj_fcn_history(iteration) = fcm_compute_objective_fcn (Mu_m, sqr_dist); + obj_fcn_history(iteration) = ... + fcm_compute_objective_fcn (Mu_m, sqr_dist); if (display_intermediate_results) printf ("Iteration count = %d, Objective fcn = %8.6f\n", ... iteration, obj_fcn_history(iteration)); endif - convergence_criterion = fcm_compute_convergence_criterion (V, V_previous); + convergence_criterion = ... + fcm_compute_convergence_criterion (V, V_previous); endwhile - ## Remove extraneous entries from the tail of the objective function history. + ## Remove extraneous entries from the tail of the objective + ## function history. if (convergence_criterion <= epsilon) obj_fcn_history = obj_fcn_history(1 : iteration); endif Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm_demo_1.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm_demo_1.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm_demo_1.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2012 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -42,16 +42,17 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy partition clustering fcm demo +## Keywords: fuzzy-logic-toolkit fuzzy partition clustering fcm ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: fcm_demo_1.m -## Last-Modified: 10 July 2012 +## Last-Modified: 19 Aug 2012 -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Note: The input_data is taken from Chapter 13, Example 17 in -## Fuzzy Logic: Intelligence, Control and Information, by J. Yen and -## R. Langari, Prentice Hall, 1999, page 381 (International Edition). -##------------------------------------------------------------------------------ +## Fuzzy Logic: Intelligence, Control and Information, by J. Yen +## and R. Langari, Prentice Hall, 1999, page 381 (International +## Edition). +##---------------------------------------------------------------------- ## Use fcm to classify the data in matrix x. input_data = [2 12; 4 9; 7 13; 11 5; 12 7; 14 4] @@ -60,22 +61,25 @@ fcm (input_data, number_of_clusters) ## Calculate and print the three validity measures. -printf ("Partition Coefficient: %f\n", partition_coeff (soft_partition)); -printf ("Partition Entropy (with a = 2): %f\n", partition_entropy (soft_partition, 2)); -printf ("Xie-Beni Index: %f\n\n", xie_beni_index (input_data, cluster_centers, soft_partition)); +printf ("Partition Coefficient: %f\n", ... + partition_coeff (soft_partition)); +printf ("Partition Entropy (with a = 2): %f\n", ... + partition_entropy (soft_partition, 2)); +printf ("Xie-Beni Index: %f\n\n", ... + xie_beni_index (input_data, cluster_centers, soft_partition)); ## Plot the data points as small blue x's. figure ('NumberTitle', 'off', 'Name', 'FCM Demo 1'); for i = 1 : rows (input_data) - plot (input_data(i, 1), input_data(i, 2), 'LineWidth', 2, 'marker', 'x', ... - 'color', 'b'); + plot (input_data(i, 1), input_data(i, 2), 'LineWidth', 2, ... + 'marker', 'x', 'color', 'b'); hold on; endfor ## Plot the cluster centers as larger red *'s. for i = 1 : number_of_clusters - plot (cluster_centers(i, 1), cluster_centers(i, 2), 'LineWidth', 4, ... - 'marker', '*', 'color', 'r'); + plot (cluster_centers(i, 1), cluster_centers(i, 2), 'LineWidth', ... + 4, 'marker', '*', 'color', 'r'); hold on; endfor Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm_demo_2.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm_demo_2.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/fcm_demo_2.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2012 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -42,44 +42,48 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy partition clustering fcm demo +## Keywords: fuzzy-logic-toolkit fuzzy partition clustering fcm ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: fcm_demo_2.m -## Last-Modified: 10 July 2012 +## Last-Modified: 19 Aug 2012 -##------------------------------------------------------------------------------ -## Note: The input_data was selected to form three areas of different shapes. -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- +## Note: The input_data was selected to form three areas of different +## shapes. +##---------------------------------------------------------------------- ## Use fcm to classify the data in matrix x. -input_data = [1 11 5; 1 12 6; 1 13 5; 2 11 7; 2 12 6; 2 13 7; 3 11 6; 3 12 5; - 3 13 7; 1 1 10; 1 3 9; 2 2 11; 3 1 9; 3 3 10; 3 5 11; 4 4 9; - 4 6 8; 5 5 8; 5 7 9; 6 6 10; 9 10 12; 9 12 13; 9 13 14; 10 9 13; - 10 13 12; 11 10 14; 11 12 13; 12 6 12; 12 7 15; 12 9 15; 14 6 14; - 14 8 13] +input_data = [1 11 5; 1 12 6; 1 13 5; 2 11 7; 2 12 6; 2 13 7; 3 11 6; + 3 12 5; 3 13 7; 1 1 10; 1 3 9; 2 2 11; 3 1 9; 3 3 10; + 3 5 11; 4 4 9; 4 6 8; 5 5 8; 5 7 9; 6 6 10; 9 10 12; + 9 12 13; 9 13 14; 10 9 13; 10 13 12; 11 10 14; 11 12 13; + 12 6 12; 12 7 15; 12 9 15; 14 6 14; 14 8 13] number_of_clusters = 3 [cluster_centers, soft_partition, obj_fcn_history] = ... fcm (input_data, number_of_clusters, [NaN NaN NaN 0]) ## Calculate and print the three validity measures. -printf ("Partition Coefficient: %f\n", partition_coeff (soft_partition)); -printf ("Partition Entropy (with a = 2): %f\n", partition_entropy (soft_partition, 2)); -printf ("Xie-Beni Index: %f\n\n", xie_beni_index (input_data, cluster_centers, soft_partition)); +printf ("Partition Coefficient: %f\n", ... + partition_coeff (soft_partition)); +printf ("Partition Entropy (with a = 2): %f\n", ... + partition_entropy (soft_partition, 2)); +printf ("Xie-Beni Index: %f\n\n", ... + xie_beni_index (input_data, cluster_centers, soft_partition)); ## Plot the data points in two dimensions (using features 1 and 2) ## as small blue x's. figure ('NumberTitle', 'off', 'Name', 'FCM Demo 2'); for i = 1 : rows (input_data) - plot (input_data(i, 1), input_data(i, 2), 'LineWidth', 2, 'marker', 'x', ... - 'color', 'b'); + plot (input_data(i, 1), input_data(i, 2), 'LineWidth', 2, ... + 'marker', 'x', 'color', 'b'); hold on; endfor ## Plot the cluster centers in two dimensions (using features 1 and 2) ## as larger red *'s. for i = 1 : number_of_clusters - plot (cluster_centers(i, 1), cluster_centers(i, 2), 'LineWidth', 4, ... - 'marker', '*', 'color', 'r'); + plot (cluster_centers(i, 1), cluster_centers(i, 2), 'LineWidth', ... + 4, 'marker', '*', 'color', 'r'); hold on; endfor @@ -97,16 +101,16 @@ ## as small blue x's. figure ('NumberTitle', 'off', 'Name', 'FCM Demo 2'); for i = 1 : rows (input_data) - plot (input_data(i, 1), input_data(i, 3), 'LineWidth', 2, 'marker', 'x', ... - 'color', 'b'); + plot (input_data(i, 1), input_data(i, 3), 'LineWidth', 2, ... + 'marker', 'x', 'color', 'b'); hold on; endfor ## Plot the cluster centers in two dimensions (using features 1 and 3) ## as larger red *'s. for i = 1 : number_of_clusters - plot (cluster_centers(i, 1), cluster_centers(i, 3), 'LineWidth', 4, ... - 'marker', '*', 'color', 'r'); + plot (cluster_centers(i, 1), cluster_centers(i, 3), 'LineWidth', ... + 4, 'marker', '*', 'color', 'r'); hold on; endfor Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gauss2mf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gauss2mf.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gauss2mf.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -64,15 +64,15 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy membership-function gaussian +## Keywords: fuzzy-logic-toolkit fuzzy membership gaussian ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: gauss2mf.m -## Last-Modified: 28 Oct 2011 +## Last-Modified: 19 Aug 2012 function y = gauss2mf (x, params) - ## If the caller did not supply 2 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 2 argument values with the correct + ## types, print an error message and halt. if (nargin != 2) puts ("Type 'help gauss2mf' for more information.\n"); @@ -85,16 +85,17 @@ error ("gauss2mf's second argument must be a parameter vector\n"); endif - ## Calculate and return the y values of the membership function on the - ## domain x according to the definition of gauss2mf given in the comment - ## above. + ## Calculate and return the y values of the membership function on + ## the domain x according to the definition of gauss2mf given in the + ## comment above. sig1 = params(1); c1 = params(2); sig2 = params(3); c2 = params(4); - f1_val = @(x_val) (x_val <= c1) * exp ((-(x_val - c1)^2)/(2 * sig1^2)) + ... + f1_val = @(x_val) (x_val <= c1) * ... + exp ((-(x_val - c1)^2)/(2 * sig1^2)) + ... (x_val > c1); f2_val = @(x_val) (x_val <= c2) + ... Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gaussmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gaussmf.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gaussmf.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -60,15 +60,15 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy membership-function gaussian +## Keywords: fuzzy-logic-toolkit fuzzy membership gaussian ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: gaussmf.m -## Last-Modified: 28 Oct 2011 +## Last-Modified: 19 Aug 2012 function y = gaussmf (x, params) - ## If the caller did not supply 2 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 2 argument values with the correct + ## types, print an error message and halt. if (nargin != 2) puts ("Type 'help gaussmf' for more information.\n"); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gbellmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gbellmf.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gbellmf.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -64,15 +64,15 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy membership-function bell-shaped bell +## Keywords: fuzzy-logic-toolkit fuzzy membership bell-shaped bell ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: gbellmf.m -## Last-Modified: 28 Oct 2011 +## Last-Modified: 19 Aug 2012 function y = gbellmf (x, params) - ## If the caller did not supply 2 argument values with the correct types, - ## print an error message and halt. + ## If the caller did not supply 2 argument values with the correct + ## types, print an error message and halt. if (nargin != 2) puts ("Type 'help gbellmf' for more information.\n"); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -70,7 +70,7 @@ ## sugeno_tip_demo.m ## @end itemize ## -## CURRENT LIMITATION: +## Current limitation: ## The form of gensurf that suppresses plotting (the final form above) is not yet ## implemented. ## @@ -78,16 +78,18 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis plot +## Keywords: fuzzy-logic-toolkit fuzzy inference system fis plot ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: gensurf.m -## Last-Modified: 11 Nov 2011 +## Last-Modified: 19 Aug 2012 -function [x, y, z] = gensurf (fis, input_axes = [1 2], output_axis = 1, ... - grids = [15 15], ref_input = [], num_points = 101) +function [x, y, z] = gensurf (fis, input_axes = [1 2], ... + output_axis = 1, grids = [15 15], ... + ref_input = [], num_points = 101) - ## If gensurf was called with an incorrect number of arguments, or the - ## arguments do not have the correct type, print an error message and halt. + ## If gensurf was called with an incorrect number of arguments, + ## or the arguments do not have the correct type, print an error + ## message and halt. if ((nargin < 1) || (nargin > 6)) puts ("Type 'help gensurf' for more information.\n"); @@ -103,32 +105,34 @@ error ("gensurf's third argument must be a valid output index\n"); elseif ((nargin >= 4) && !is_grid_spec (grids)) puts ("Type 'help gensurf' for more information.\n"); - error ("gensurf's fourth argument must be a valid grid specification\n"); + error ("gensurf's 4th argument must be a grid specification\n"); elseif ((nargin >= 5) && !is_ref_input (ref_input, fis, input_axes)) puts ("Type 'help gensurf' for more information.\n"); - error ("gensurf's fifth argument must specify reference input values\n"); - elseif ((nargin == 6) && !(is_pos_int (num_points) && (num_points >= 2))) + error ("gensurf's 5th argument must be reference input values\n"); + elseif ((nargin == 6) && ... + !(is_pos_int (num_points) && (num_points >= 2))) puts ("Type 'help gensurf' for more information.\n"); - error ("gensurf's sixth argument to gensurf must be an integer >= 2\n"); + error ("gensurf's sixth argument must be an integer >= 2\n"); endif if (length (input_axes) == 1 || columns (fis.input) == 1) - generate_plot (fis, input_axes, output_axis, grids, ref_input, num_points); + generate_plot (fis, input_axes, output_axis, grids, ... + ref_input, num_points); else - generate_surface (fis, input_axes, output_axis, grids, ref_input, ... - num_points); + generate_surface (fis, input_axes, output_axis, grids, ... + ref_input, num_points); endif endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Function: generate_plot ## Purpose: Generate a plot representing one of the FIS outputs as a ## function of one of the FIS inputs. -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- -function [x, y, z] = generate_plot (fis, input_axis, output_axis, grids, ... - ref_input, num_points) +function [x, y, z] = generate_plot (fis, input_axis, output_axis, ... + grids, ref_input, num_points) ## Create input to FIS using grid points and reference values. @@ -163,14 +167,14 @@ endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Function: generate_surface -## Purpose: Generate a surface representing one of the FIS outputs as a -## function of two of the FIS inputs. -##------------------------------------------------------------------------------ +## Purpose: Generate a surface representing one of the FIS outputs as +## a function of two of the FIS inputs. +##---------------------------------------------------------------------- -function [x, y, z] = generate_surface (fis, input_axes, output_axis, grids, ... - ref_input, num_points) +function [x, y, z] = generate_surface (fis, input_axes, output_axis, ... + grids, ref_input, num_points) ## Create input to FIS using grid points and reference values. @@ -203,7 +207,8 @@ ## Compute the output and reshape it to fit the grid. output = evalfis_private (fis_input, fis, num_points); - z_matrix = reshape (output(:, output_axis), length (x_axis), length (y_axis)); + z_matrix = reshape (output(:, output_axis), length (x_axis), ... + length (y_axis)); ## Plot the surface. Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m 2012-08-24 16:11:37 UTC (rev 10908) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m 2012-08-24 16:13:07 UTC (rev 10909) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> +## Copyright (C) 2011-2012 L. Markowsky <lm...@us...> ## ## This file is part of the fuzzy-logic-toolkit. ## @@ -90,15 +90,16 @@ ## @end deftypefn ## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis +## Keywords: fuzzy-logic-toolkit fuzzy inference system fis ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: getfis.m -## Last-Modified: 31 Oct 2011 +## Last-Modified: 20 Aug 2012 -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- function retval = getfis (fis, arg2 = 'dummy', arg3 = 'dummy', ... - arg4 = 'dummy', arg5 = 'dummy', arg6 = 'dummy') + arg4 = 'dummy', arg5 = 'dummy', ... + arg6 = 'dummy') switch (nargin) case 1 retval = getfis_one_arg (fis); @@ -106,7 +107,8 @@ case 3 retval = getfis_three_args (fis, arg2, arg3); case 4 retval = getfis_four_args (fis, arg2, arg3, arg4); case 5 retval = getfis_five_args (fis, arg2, arg3, arg4, arg5); - case 6 retval = getfis_six_args (fis, arg2, arg3, arg4, arg5, arg6); + case 6 retval = getfis_six_args (fis, arg2, arg3, arg4, arg5, ... + arg6); otherwise puts ("Type 'help getfis' for more information.\n"); error ("getfis requires 1-6 arguments\n"); @@ -114,11 +116,11 @@ endfunction -##------------------------------------------------------------------------------ +##---------------------------------------------------------------------- ## Function: getfis_one_arg -## Purpose: Handle calls to getfis that have 1 argument. -## See the comment at the top of this file for more complete info. -##------------------------------------------------------------------------------ +## Purpose... [truncated message content] |