# Matlab Gatool

Good Essays
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.

[pic]

It should be noted that the Matlab Genetic

• Good Essays

## Matlab

• 18263 Words
• 74 Pages

An Introduction to Matlab Version 2.3 David F. Griﬃths Department of Mathematics The University Dundee DD1 4HN With additional material by Ulf Carlsson Department of Vehicle Engineering KTH, Stockholm, Sweden Copyright c 1996 by David F. Griﬃths. Amended October, 1997, August 2001, September 2005. This introduction may be distributed provided that it is not be altered in any way and that its source is properly and completely speciﬁed. Contents 1 MATLAB 2 Starting Up 2.1 Windows Systems…

• 18263 Words
• 74 Pages
Good Essays
• Better Essays

## Matlab

• 4159 Words
• 17 Pages

MATLAB BEGINNER’S GUIDE 0 About MATLAB MATLAB is an interactive software which has been used recently in various areas of engineering and scientific applications. It is not a computer language in the normal sense but it does most of the work of a computer language. Writing a computer code is not a straightforward job, typically boring and time consuming for beginners. One attractive aspect of MATLAB is that it is relatively easy to learn. It is written on an intuitive basis and it does not…

• 4159 Words
• 17 Pages
Better Essays
• Good Essays

## MATLAB

• 1938 Words
• 20 Pages

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 lab sessions – Remember - MATLAB labs will be…

• 1938 Words
• 20 Pages
Good Essays
• Powerful Essays

## Matlab

• 2459 Words
• 13 Pages

3217 DECEMBER 9, 2008 WILLIAM E. BRUNS SHARON M. BRUNS SUSAN HARMELING Merrimack Tractors and Mowers, Inc.: LIFO or FIFO? Ricardo “Rick” Martino, president and chief operating officer of Merrimack Tractors and Mowers, Inc., of Nashua, New Hampshire, felt that his job had grown much more complicated during 2007 and 2008. Merrimack was a major regional manufacturer and seller of large commercial grass mowers based on a design developed by his grandfather in the years after World War II…

• 2459 Words
• 13 Pages
Powerful Essays
• Good Essays

Section 2.2 Matrices in Matlab 75 2.2 Matrices in Matlab You can think of a matrix as being made up of 1 or more row vectors of equal length. Equivalently, you can think of a matrix of being made up of 1 or more column vectors of equal length. Consider, for example, the matrix   1 2 3 0 A =  5 −1 0 0  . 3 −2 5 0 One could say that the matrix A is made up of 3 rows of length 4. Equivalently, one could say that matrix A is made up of 4 columns of length 3. In either model, we have 3 rows…

• 6867 Words
• 28 Pages
Good Essays
• Powerful Essays

AP Induction Week Course Introduction to Engineering Computation Laboratory Manual MATLAB programming Department of Engineering Science MATLAB Laboratory Manual Contents Laboratory 1: An introduction to MATLAB ............................................................................................ 2 Laboratory 2: Debugging, Functions and Problem Solving ............................................................22 Laboratory 3: Logical Operators, Conditional Statements and Loops…

• 11755 Words
• 48 Pages
Powerful Essays
• Powerful Essays

College of Engineering ELECTRONICS AND COMMUNICATIONS ENGINEERING NDC Compound, *Anonas* St. Sta. Mesa, Manila {draw:line} Research Work with Defense Submitted By: Group 3 - Alpha Signal Rho BSECE IV-1 Leader : SANTOS, Ralph Rhyan G. Members: BELANO, Gracielle D. ESPINOSA, Joey Q. HERNANDEZ, Jan Roldan B. MATIC, Millicent G. RIVO, Sarah Ezekiel M. VILLENA, Kane Dave R Engr. Gerhard P. Tan Instructor Introduction It is known that our fast-paced…

• 2235 Words
• 9 Pages
Powerful Essays
• Good Essays

INTRODUCTION TO MATLAB © Dr. James S. Kang, Professor, ECE Department, Cal Poly Pomona Opening MATLAB Start → Programs → MATLAB → R2010a → MATLAB R2010a or double click on icon ( ). Slightly different for different versions and operating systems. The MATLAB window opens up as shown below. Depending on Desktop options, the window looks different. Set the Current Folder on top of the screen. Working on Command Window We are demonstrating the use of Command Window by solving HW Problem 1.9 1.9 The…

• 832 Words
• 8 Pages
Good Essays
• Better Essays

Matlab 1.1.7 f(n) = u(n)-n(n-4) n = -5:5; f = (n >= 0); g = (n >= 4); stem (n,(f-g)) g(n)=r(n)-2r(n-5)+r(n-10) n = -15:15; r = n.*(n >= 0); f = (n-5).*((n-5)>=0); h = (n-10).*((n-10)>=0); g = r - 2.*f + h; stem (n,g) x(n) = δ(n) - 2δ(n-4) n = -5:5; f = (n == 0); g = ((n-4)==0); x = f - 2.*g stem (n,x) y(n) = (0.9)^n (u(n)-u(n-20)) n = -20:20; f = (n >= 0); g = ((n-20)>=0); y = 0.9.^n.*(f-g); stem (n,y) v(n) = cos…

• 554 Words
• 3 Pages
Better Essays
• Better Essays

DOI 10.5162/IMCS2012/PT1 Gas Sensors Status and Future Trends for Safety Applications Tesshi Shigemori Chairman of Gas Alarm Industries Association of Japan, Regular Associate Director of Japan Safety Appliances Association, and President of New Cosmos Electric Co., Ltd. Email: shigemori.tesshi@new-cosmos.co.jp 2-5-4 Mitsuya-naka,Yodogawa-ku,Osaka 532-0036, JAPAN Abstract: Actually there are many measures to prevent accidents caused by gas leaks and/or gas generations. However, only…

• 1699 Words
• 7 Pages
Better Essays