Using Matlab to Execute a Genetic Algorithm
Optimization of Two Variable Function

The function to be optimized is given by:

[pic]

The maximum value of this two variable function is desired, however Matlab’s gatool finds the minimum of fitness functions and so as in the previous example the function must be altered as follows:

[pic]

Now we must enter this function, as before, into a Matlab function file.

Start Matlab and change the working directory to your Knowledge Based Systems folder. (i.e. U:\Current Class\KBS\) Create an m-file by either typing “edit fitness2” at the command prompt, or clicking the new file icon on the toolbar.

The Matlab Genetic Algorithm accepts multiple variable functions, however these variables must be contained in an array. Therefore every “x” in the above equation is replaced with “x(1)” and every “y” with “x(2)”. Once the m-file editor is open, enter the following code:

function y = fitness2(x)
y = -((1-x(1))^2*exp(-x(1)^2-(x(2)+1)^2) - (x(1) - x(1)^3 - x(2)^3)*exp(-x(1)^2-x(2)^2)); end

Save the file. (Note: The file must be saved under the same name as the function name. i.e. fitness2 as shown above)

In the Matlab command window type “gatool”. This will open the genetic algorithm tool as shown in Figure 1.

[pic]

Enter the name of your fitness function in the Fitness function text box preceded with an @ symbol as shown in Figure 1. Enter 2 for the number of variables and select Best fitness as the plot option.

Run the solver with all the default settings and observe results similar to Figure 2.

[pic]

The optimum value of x can be seen after the simulation in the gatool window in the Final point field. Record this number

Next modify the number of generations in the “Stopping Criteria” drop box. Change the number of generations to 25 and re-run the solution. Your results should resemble those of Figure 3.

...Experiment # 1
Title: Starting with MATLAB.
Equipment Required: Personal computer (PC) with windows operating system and MATLAB software
Theory:-
MATLAB is a powerful computing system for handling the calculations involved in scientific and engineering problems. The name MATLAB stands for MATrix LABoratory, because the system was designed to make matrix computations particularly easy.
One of the many things about...

...DISCUSSION:
After using both languages, Microsoft Excel and MATLAB (MATrix LABoratory), on the same module experiments from 1 to 4, I observed the following:
* For Microsoft excel,
* It uses spreadsheet application where each elements or data values are distributed in cells.
* Most statistical computations are easy to solve due to the manner of data organization where data are inserted on cells arranged in numbered rows and letter-named columns.
*...

...components
– MATLAB – Revision, Numerical Integration, Root
Finding
• Dr Mike Clee
• Lectures – Weeks 2-4, Labs – Weeks 3-5
• 50% 1 assignment
– CAD – Solidworks
• Dr Chengyuan Wang
• Lectures Weeks 5-6, Labs – Weeks 6-12
• 50% – 1 assignments
Semester 1, 2014-2015
General Information
• MATLAB lab slots
– There will be demonstrators in each lab to help with MATLAB
worksheets
– Each student has the opportunity to complete the assignment during
the...

...MATLAB EXERCISES
UEMH3163 / UECS2053 ARTIFICIAL INTELLIGENCE
1. Run the MATLAB code:
a = 1:5;
d = a+i*a;
e = d'
f = d.'
g = mod(5,4)
2. Given A = [1 2 4; 1 1 1; 2 3 1] and B = [2 2 2; 2 2 2; 2 2 2]. Run the MATLAB code:
a=A>B
b=A>1
3. Given A = magic(4). Run MATLAB code :
DiagElement = diag(A)
DiagMatrix = diag(diag(A))
SuperDiagElement = diag(A,2)
4. Run the MATLAB code:
name =...

...MATLAB Parallel Computing
John Burkardt (ARC/ICAM) & Gene Cliﬀ (AOE/ICAM) Virginia Tech .......... FDI Fall Short Course: Introduction to Parallel MATLAB at Virginia Tech http://people.sc.fsu.edu/∼burkardt/presentations/fdi matlab 2009.pdf .......... ARC: Advanced Research Computing AOE: Department of Aerospace and Ocean Engineering ICAM: Interdisciplinary Center for Applied Mathematics
09 September 2009
Burkardt MATLAB Parallel...

...INGE3016 Algorithms and Computer Programming with MATLAB
First Semester 2010-2011
COMPUTER PROJECT#1
Due on Tuesday, Spetember 13th, 2011
As this is the first program, the solution is provided. Most of the code details will be covered in class, as we progress. Therefore, at this point don’t worry if you don’t understand completely all the statements. The objective of this project is just to be able to edit, compile and run a full MATLAB program while...

... ASSISTANT PROFESSOR
CONTENTS:
1)Experiment 1: INTRODUCTION WITH MATLAB SOFTWARE
2) Experiment 2: GENERATION OF BASIC CONTINUES SIGNALS / BASIC DISCRETE SIGNALS
3) Experiment 3: IMPULSE RESPONSE OF AN LTI SYSTEM
4) Experiment 4: CONVOLUTION OF TWO SEQUENCE AND PROPERTIES OF CONVOLUTION
5) Experiment 5: CORRELATION- AUTOCORRELATION
6) Experiment 6: read and display digital image using MATLAB
7) Experiment 7: remove noise using spatial filters....

2966 Words |
17 Pages

Share this Document

Let your classmates know about this document and more at StudyMode.com

## Share this Document

Let your classmates know about this document and more at StudyMode.com