Você está na página 1de 13

function [bc] = triangle(a,b,c,x)

if x<a,
ds=0;
elseif x>=a && x<b,
ds=(x-a)/(b-a);
elseif x>=b && x<c,
ds= (c-x)/(c-b);
elseif x>=c,
ds=0;
end
bc=ds;
end

function [ d ] = trapezoid( a,b,c,d,x )


if x<a,
d=0;
elseif x>=a & x<b,
d= (x-a)/(b-a);
elseif x>=b & x<c,
d=1;
elseif x>=c & x<d,
d=(d-x)/(d-c);
elseif x>=d,
d=0;
end;

end

function [ sedikit ] = sedikit( position )


%UNTITLED10 Summary of this function goes here
%
Detailed explanation goes here
sedikit= triangle(0,1,2,position);
end

function [ sedang ] = sedang( position )


%UNTITLED11 Summary of this function goes here
%
Detailed explanation goes here
sedang= triangle(1,2,3,position);
end

function [ a ] = B( error,derror )
%UNTITLED9 Summary of this function goes here
%
Detailed explanation goes here
b1=B1(error,derror);
b2=B2(error,derror);
b3=B3(error,derror);
b4=B4(error,derror);

b5=B5(error,derror);
if b1>b2 & b1>b3 & b1>b4 & b1>b5,
a=b1;
elseif b2>b1 & b2>b3 & b2>b4 & b2>b5,
a=b2;
elseif b3>b1 & b3>b2 & b3>b4 & b3>b5,
a=b3;
elseif b4>b1 & b4>b2 & b4>b3 & b4>b5,
a=b4;
elseif b5>=b1 & b5>=b2 & b5>=b3 & b5>=b4,
a=b5;
end

end

function [ a ] = B1( error,derror )


%UNTITLED13 Summary of this function goes here
%
Detailed explanation goes here
b1= error_pb(error);
b2= derror_pb(derror);
if b1<b2,
a=b1;
else
a=b2;
end
end

function [ a ] = B2( error,derror )


%UNTITLED14 Summary of this function goes here
%
Detailed explanation goes here
b1=error_ps(error);
b2=derror_pb(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ a ] = B3( error,derror )


%UNTITLED15 Summary of this function goes here
%
Detailed explanation goes here
b1=error_pb(error);
b2=derror_ps(derror);
if b1<b2,
a=b1;

else
a=b2;
endfunction [ a ] = B4( error,derror )
%UNTITLED16 Summary of this function goes here
%
Detailed explanation goes here
b1=error_ps(error);
b2=derror_ps(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end
end
function [ a ] = B5( error,derror )
%UNTITLED17 Summary of this function goes here
%
Detailed explanation goes here
b1=error_pb(error);
b2=derror_pk(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ a ] = S4( error,derror )


%UNTITLED4 Summary of this function goes here
%
Detailed explanation goes here
b1=error_pk(error);
b2=derror_z(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [PK ] = error_pk( position )


%UNTITLED2 Summary of this function goes here
%
Detailed explanation goes here
PK= triangle (2,4,6,position);
end

function [PS ] = error_ps( position )


%UNTITLED Summary of this function goes here
%
Detailed explanation goes here
PS= triangle(5,10,15,position);
end

function [ Z ] = error_z( position )


%UNTITLED3 Summary of this function goes here
%
Detailed explanation goes here
if position<-1,
position=-1;
end;
Z= trapezoid (-3,-1,2,3,position);
end

function [ a ] = fuzzy_out( error,derror )


%UNTITLED13 Summary of this function goes here
%
Detailed explanation goes here
b1=M(error,derror);
b2=S(error,derror);
b3=SD(error,derror);
b4=B(error,derror);
a1=b1*0;
a2=b2*1;
a3=b3*2;
a4=b4*3.5;
out1= a1+a2+a3+a4;
out2=b1+b2+b3+b4;
a= out1/out2;

end

function [ a ] = M( error,derror )
b1=M1(error,derror);
b2=M2(error,derror);
b3=M3(error,derror);
if b1>b2 & b1>b3,
a=b1;
elseif b2>b1 & b2>b3,
a=b2;

elseif b3>=b1 & b3>=b2,


a=b3;
end
end

function [ a ] = M1( error,derror )


%UNTITLED5 Summary of this function goes here
%
Detailed explanation goes here
b1=error_z(error);
b2=derror_ps(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ a ] = M2( error,derror )


%UNTITLED6 Summary of this function goes here
%
Detailed explanation goes here
b1=error_z(error);
b2=derror_pk(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ a ] = M3( error,derror )


%UNTITLED7 Summary of this function goes here
%
Detailed explanation goes here
b1=error_z(error);
b2=derror_z(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ M ] = mati( position )


%UNTITLED8 Summary of this function goes here
%
Detailed explanation goes here
M= triangle (-0.5,0,0.5,position);
end

function varargout = mex(varargin)


%MEX
Compile MEX-function
%
%
Usage:
%
mex [options ...] file [files ...]
%
%
Description:
%
MEX compiles and links source files into a shared library called a
%
MEX-file, executable from within MATLAB. The resulting file has a
%
platform-dependent extension. Use the MEXEXT command to return the
%
extension for this machine or for all supported platforms.
%
%
MEX accepts any combinations of source files, object files, and
%
library files as arguments.
%
%
The command line options to MEX are defined in the "Command Line
%
Options" section below.
%
%
MEX can also build executable files for stand-alone MATLAB engine
%
and MAT-file applications. See the "Engine/MAT Stand-alone
%
Application Details" below for more information.
%
%
You can run MEX from the MATLAB Command Prompt, Windows Command
%
Prompt, or the UNIX shell. MEX is a script named mex.bat on Windows
%
and mex on UNIX, and is located in the directory specified by
%
[matlabroot '/bin'].
%
%
The first file name given (less any file name extension) will be the
%
name of the resulting MEX-file. Additional source, object, or
%
library files can be given to satisfy external references. On UNIX,
%
both C and Fortran source files can be specified when building a
%
MEX-file. If C and Fortran are mixed, the first source file given
%
determines the entry point exported from the MEX-file (MATLAB loads
%
and runs a different entry point symbol for C or Fortran MEX-files).
%
%
MEX uses an options file to specify variables and values that are
%
passed as arguments to the compiler, linker, and other tools (e.g.
%
the resource linker on Windows). Command line options to MEX may
%
supplement or override contents of the options file, or they may
%
control other aspects of MEX's behavior. For more information see
%
the "Options File Details" section below.
%
%
The -setup option causes MEX to search for installed compilers and
%
allows you to choose an options file as the default for future
%
invocations of MEX. For compiler configuration information,
%
use the mex.getCompilerConfigurations function.
%

%
For a list of compilers supported with this release, refer to
%
the Supported and Compatible Compiler List at:
%
http://www.mathworks.com/support/compilers/current_release/
%
%
Command Line Options Available on All Platforms:
%
-<arch>
%
Build an output file for architecture <arch>. To determine the
%
value for <arch>, type "computer('arch')" at the MATLAB Command
%
Prompt on the target machine. Note: Valid values for <arch>
%
depend on the architecture of the build platform.
%
-argcheck
%
This option has been removed.
%
-c
%
Compile only. Creates an object file but not a MEX-file.
%
-compatibleArrayDims
%
Build a MEX-file using the MATLAB Version 7.2 array-handling API,
%
which limits arrays to 2^31-1 elements. This option is the
%
default, but in the future the -largeArrayDims option will be
%
the default.
%
-D<name>
%
Define a symbol name to the C preprocessor. Equivalent to a
%
"#define <name>" directive in the source. Do not add a space
after
%
this switch.
%
-D<name>=<value>
%
Define a symbol name and value to the C preprocessor. Equivalent
%
to a "#define <name> <value>" directive in the source. Do not add
a
%
space after this switch.
%
-f <optionsfile>
%
Specify location and name of options file to use. Overrides
%
MEX's default options file search mechanism.
%
-g
%
Create a MEX-file containing additional symbolic information for
%
use in debugging. This option disables MEX's default behavior of
%
optimizing built object code (see the -O option).
%
-h[elp]
%
Print this message.
%
-I<pathname>
%
Add <pathname> to the list of directories to search for #include
%
files. Do not add a space after this switch.
%
-l<name>
%
Link with object library. On Windows, name expands to
%
"<name>.lib" or "lib<name>.lib" and on UNIX, to
%
"lib<name>.LIBEXT", where LIBEXT is platform dependent. Do not
%
add a space after this switch.
%
-L<directory>
%
Add <directory> to the list of directories to search for
%
libraries specified with the -l option. On UNIX systems, you
%
must also set the run-time library path. Do not add a space
%
after this switch.
%
-largeArrayDims
%
Build a MEX-file using the MATLAB large-array-handling API. This
%
API can handle arrays with more than 2^31-1 elements when
%
compiled on 64-bit platforms. (See also the -compatibleArrayDims
%
option.)
%
-n

%
No execute mode. Print out any commands that MEX would otherwise
%
have executed, but do not actually execute any of them.
%
-O
%
Optimize the object code. Optimization is enabled by default and
%
by including this option on the command line. If the -g option
%
appears without the -O option, optimization is disabled.
%
-outdir <dirname>
%
Place all output files in directory <dirname>.
%
-output <resultname>
%
Create MEX-file named <resultname>. The appropriate MEX-file
%
extension is automatically appended. Overrides MEX's default
%
MEX-file naming mechanism.
%
-setup
%
Specify the compiler options file to use when calling the mex
%
function. When this option is specified, no other command line
%
input is accepted.
%
-U<name>
%
Remove any initial definition of the C preprocessor symbol
%
<name>. (Inverse of the -D option.) Do not add a space after this
%
switch.
%
-v
%
Verbose mode. Print the values for important internal variables
%
after the options file is processed and all command line
%
arguments are considered. Prints each compile step and final link
%
step fully evaluated.
%
<name>=<value>
%
Override an options file variable for variable <name>.
%
This option is processed after the options file is processed
%
and all command line arguments are considered. See the
%
"Override Option Details" section below for more details.
%
%
Command Line Options Available Only on Windows Platforms:
%
@<rspfile>
%
Include contents of the text file <rspfile> as command line
%
arguments to MEX.
%
%
Command Line Options Available Only on UNIX Platforms:
%
-cxx
%
Use the C++ linker to link the MEX-file if the first source file
%
is in C and there are one or more C++ source or object files.
This
%
option overrides the assumption that the first source file in
%
the list determines which linker to use.
%
-fortran
%
Specify that the gateway routine is in Fortran. This option
%
overrides the assumption that the first source file in the list
%
determines which linker to use.
%
%
Options File Details:
%
There are template options files for the compilers that are
%
supported by MEX. These templates are located at
%
[matlabroot '\bin\win32\mexopts'] or
%
[matlabroot '\bin\win64\mexopts'] on Windows, or
%
[matlabroot '/bin'] on UNIX.
%
%
These template options files are used by the -setup option to define
%
the selected default options file.

%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%

Override Option Details:


Use the name=value command-line argument to override a variable
specified in the options file at the command line. When using this
option, you may need to use the shell's quoting syntax to protect
characters such as spaces, which have a meaning in the shell syntax.
On Windows platforms, at either the MATLAB prompt or the DOS prompt,
use double quotes ("):
mex -v COMPFLAGS="$COMPFLAGS -Wall" ...
LINKFLAGS="$LINKFLAGS /VERBOSE" yprime.c
At the MATLAB command line on UNIX platforms, use double quotes (").
Use the backslash (\) escape character before the dollar sign ($).
mex -v CFLAGS="\$CFLAGS -Wall" LDFLAGS="\$LDFLAGS -w" yprime.c
At the shell command line on UNIX platforms, use single quotes ('):
mex -v CFLAGS='$CFLAGS -Wall' LDFLAGS='$LDFLAGS -w' yprime.c
Engine/MAT Stand-alone Application Details:
For stand-alone engine and MAT-file applications, MEX does not use
the default options file; you must use the -f option to specify
an options file.
The options files used to generate stand-alone MATLAB engine and
MAT-file executables are named *engmatopts.bat on Windows, or
engopts.sh and matopts.sh on UNIX, and are located in the same
directory as the template options files referred to in the "Options
File Details" section.
Examples:
The following command compiles "yprime.c", building a MEX-file:
mex yprime.c
When debugging, it is often useful to use "verbose" mode as well
as include symbolic debugging information:
mex -v -g yprime.c
See also MEXEXT, MEX.GETCOMPILERCONFIGURATIONS, DBMEX, LOADLIBRARY,
PCODE, PREFDIR

% Copyright 1984-2006 The MathWorks, Inc.


% This is an autogenerated file. Do not modify.
try
[varargout{1:nargout}]=mex_helper(varargin{:});
catch exception
throw(exception);
end
function [ a ] = S( error,derror )
%UNTITLED11 Summary of this function goes here
%
Detailed explanation goes here
b1=S1(error,derror);

b2=S2(error,derror);
b3=S3(error,derror);
b4=S4(error,derror);
if b1>b2 & b1>b3 & b1>b4,
a=b1;
elseif b2>b1 & b2>b3 & b2>b4,
a=b2;
elseif b3>b1 & b3>b2 & b3>b4,
a=b3;
elseif b4>=b1 & b4>=b2 & b4>=b3,
a=b4;
end
end

function [ a ] = S1( error,derror )


%UNTITLED Summary of this function goes here
%
Detailed explanation goes here
b1=error_z(error);
b2=derror_pb(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ a ] = S2(error,derror )
%UNTITLED2 Summary of this function input_argsgoes here
%
Detailed explanation goes here
b1=error_pk(error);
b2=derror_pk(derror);
if b1<b2,
a=b1;
else
a=b2;
end
end

function [ a ] = S3( error,derror )


%UNTITLED3 Summary of this function goes here
%
Detailed explanation goes here
b1=error_ps(error);
b2=derror_z(derror);
if b1<b2,
a=b1;
else
a=b2;

end

end

function [ a ] = S4( error,derror )


%UNTITLED4 Summary of this function goes here
%
Detailed explanation goes here
b1=error_pk(error);
b2=derror_z(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [c] = SD( error,derror )


%UNTITLED12 Summary of this function goes here
%
Detailed explanation goes here
b1=SD1(error,derror);
b2=SD2(error,derror);
b3=SD3(error,derror);
b4=SD4(error,derror);
if b1>=b2 & b1>=b3 & b1>=b4,
c=b1;
elseif b2>=b1 & b2>=b3 & b2>=b4,
c=b2;
elseif b3>=b1 & b3>=b2 & b3>=b4,
c=b3;
elseif b4>=b1 & b4>=b2 & b4>=b3,
c=b4;
end
end

function [ a ] = SD1( error,derror )


%UNTITLED18 Summary of this function goes here
%
Detailed explanation goes here
b1=error_pk(error);
b2=derror_pb(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ a ] = SD2( error,derror )


%UNTITLED19 Summary of this function goes here
%
Detailed explanation goes here
b1=error_pk(error);
b2=derror_ps(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ a ] = SD3( error,derror )


%UNTITLED20 Summary of this function goes here
%
Detailed explanation goes here
b1=error_ps(error);
b2=derror_pk(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ a ] = SD4( error,derror )


%UNTITLED21 Summary of this function goes here
%
Detailed explanation goes here
b1=error_pb(error);
b2=derror_z(derror);
if b1<b2,
a=b1;
else
a=b2;
end

end

function [ sedang ] = sedang( position )


%UNTITLED11 Summary of this function goes here
%
Detailed explanation goes here
sedang= triangle(1,2,3,position);

end

Você também pode gostar