matlab tutorials


Posted on Updated on

The gatool in MATLAB provides researchers with the ability to quickly apply optimization techniques to problems that need a genetic algorithm. As with all toolboxes contained in MATLAB the gatool has a command line interface and a GUI interface. We will be using the GUI interface since it provides an easier means of modifying the parameters of the toolbox. The gatool implements a canonical genetic algorithm, with the ability to provide custom functions for mutation, crossover and selection operators. Before going any further lets review Introduction To MathWorks MATLAB. Now that you are back lets see how this can be done.

We will need to create two functions for use with the gatool (1)objective function, (2)creation function. The objective function will be minimized by the genetic algorithm to give an ideal solution for our problem definition. While the creation function will be used to create initial individuals for the genetic algorithm population.

Objective Function:

function rtn = objective(param)
seq = [1 2 3 4 5];
temp = 5;
for i = 1:length(param)
 if eq(seq(i),floor(param(i)))
 temp = temp - 1;
rtn = temp;

Creation Function:

function rtn = creator(genomeLength, fitnessFn, options)
temp = floor(5.*rand(5,1));
rtn = temp';

Gocha’s: Arguements for the respective functions must be provided otherwise the toolbox will not be able to provide the necessary parameters to the functions.

Launch gatool-> Type gatool in the MATLAB command window

GATOOL Interface: Only parameters marked in red were modified.

Results: Click the start button on the gatool to start the optimization routine.

Results Plot:

This post intends to use the gatool present in MATLAB to evolve a vector of integers from 1 to 5. If you take the floor of the final point listings you will see that this aim was achieved with 0.0 fitness.  As an exercise you could modify the other parameters present in the gatool and re-run the routine to observe any changes that may occur.

Introduction To MathWorks MATLAB

Posted on Updated on

MathWorks MATLAB® is a high-level language and interactive environment that enables you to perform computationally intensive tasks faster than with traditional programming languages such as C, C++, and Fortran. MATLAB allows for fast prototyping and testing of problems involving simulations, image processing, statistics, artificial intelligence and search/optimization requirements. These capabilities are provided by toolboxes such as Simulink, NN toolbox, Image Processing toolbox and Search/Optimization toolbox.

MATLAB is built on a foundation of matrices therefore all operations involve some form of matrix or vector manipulation, this makes it an ideal tool for use in Discrete Mathematics and Linear Algebra. MATLAB also comes packed with many common mathematical functions and operations, it also has the ability for easy graphing and display of data using generated reports.

Function Syntax:

function rtn = creator(option, state, flags)
temp = floor(5.*rand(5,1)); % ; turn off echo to command window.
rtn = temp';

Basic commands:

clc   % clears command window
clear % clears workspace window
plot  % displays the plot window

MATLAB Cheat Sheet

MATLAB Tutorials