Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

matlab: how to use genetic algorithm?

Not open for further replies.


Newbie level 5
Oct 27, 2009
Reaction score
Trophy points
Activity points
doing project on embedded with matlab

hai everybody

i am saravanan. doing project on embedded with matlab.

overview of my project ==>three sensors are used to sense the vehicle movements in three different road.

if any vehicle moves any road, that correspondent sensor will gives the data to pic micro controller IC. then that IC give the parallel data to MATLAB and again the matlab serial data will be given to the micro controller.....

here i use GENETIC ALGORITHM in matlab......

how can i use it. and also how can i inject parallel data to matlab input

doing project on embedded with matlab

use PC parallel port or Serial port (COM port), you can use USB too either by using a Matlab USB VISA object (read about them in matlab help) or use USB-serial bridge like FTDI232 chip.
you can use PIC18F4550 micrcontroller to receive data from the sensors and download CDC firmware on it (free from microchip), you will connect it to USB but your PC will recognize it a virtual COM port which you can easily handle by matlab as a COM port (serial port).
good luck

doing project on embedded with matlab

Dear Sir,

may i use PIC 16F877A instead of using PIC18F4550 micro-controller.

then, is there any comments are available in matlab to get the data from the PIC Ic (i.e) matlab input comment.

the input data [assume three sensor A B C then put the value to corespondent sensor that values are may be 1 2 3 respectively ] is either number or character.

doing project on embedded with matlab

PIC16F877 has a USART, then use the serial port interface which is available in matlab, just you will need MAX232 line driver IC.
search in matlab help about serial port or COM port interfacing, on the microcontroller side learn from the compiler help how to initiate serial communication with PC, to test your system you can use hyper terminal.
very easy, don't worry :)

good luck

Re: doing project on embedded with matlab

do you know the GENETIC ALGORITHM for transfer the data from the parallel port.and do you have any algorithm or sample code for it in matlab


doing project on embedded with matlab

actually no and i know nothing about genetics, the matter is all about data acquisition from the port and let the matlab save these data in a buffer or a file then process these data using the algorithm you want.

Re: doing project on embedded with matlab

I my MATLAB start menu the data acquisition toolbox is there.

but how can i use it. and tell me the purpose of the toolbox,why we need this explain me.

give toolbox downloading it is free or.....amount?
tell me.

doing project on embedded with matlab

just search the help or even the internet how to interface serial port using matlab, you will find all functions and API's used in the Data acq. toolbox.

doing project on embedded with matlab

just type help serial in the command window of matlab then you will see the following results with an example;

SERIAL Construct serial port object.

S = SERIAL('PORT') constructs a serial port object associated with
port, PORT. If PORT does not exist or is in use you will not be able
to connect the serial port object to the device.

In order to communicate with the device, the object must be connected
to the serial port with the FOPEN function.

When the serial port object is constructed, the object's Status property
is closed. Once the object is connected to the serial port with the
FOPEN function, the Status property is configured to open. Only one serial
port object may be connected to a serial port at a time.

S = SERIAL('PORT','P1',V1,'P2',V2,...) constructs a serial port object
associated with port, PORT, and with the specified property values. If
an invalid property name or property value is specified the object will
not be created.

Note that the property value pairs can be in any format supported by
the SET function, i.e., param-value string pairs, structures, and
param-value cell array pairs.

% To construct a serial port object:
s1 = serial('COM1');
s2 = serial('COM2', 'BaudRate', 1200);

% To connect the serial port object to the serial port:

% To query the device.
fprintf(s1, '*IDN?');
idn = fscanf(s1);

% To disconnect the serial port object from the serial port.

See also serial/fopen.

Overloaded methods:

Re: doing project on embedded with matlab

actually i am using matlab R2007b version 7.5

now i got separate toolbox for genetic algorithm(Genetic Algorithm and Direct Search Toolbox)in my matlab start menu.

Is this toolbox is enough for connecting the parallel port to the PC? or otherwise we want data acquisition toolbox?

please tell me...

i have separate embedded C code for acquiring parallel data to the pc.

in my GA toolbox i have fitness function, then i can specify the function as a function handle of the form @objfun, where objfun.m is an M-file.

how can i call the parallel data code(embedded code) in that fitness function.... please explain it in plane English.

doing project on embedded with matlab

as i know,

Matlab can do interface with the serial port only.

I do not know more!!!


doing project on embedded with matlab

I know that older versions of matlab support parallel port interfacing, i don't know if 2007b support it or not, search the help anyway.

if any body know how to operate the genetic algorithm toolbox in matlab R2007b version 7.5, please mail me.

because still now i cant get clear idea about this topic....

so please help me...


i think the matlab can interface with other port and can use it's toolbox but i dont try to use it late

I believe by now you would have understood the application of genetic algorithm toolbox.Well i carried out theoretical analysis in design of PID controller and simulation in matlab.I used MAtlab for the purpose of parameter optimization.As a mater of fact i didnt use the genetic algorithm toolbox as i used a lower version of matlab than yours. wrote code for all requirements though its a tedious thing to do as i had a superior who can guide me when i get struck....I have no idea about Interfacing part but apart from that Genetic algorithm part make a post i will try what i can to answer it... all the best.

doubts on 3d model

i have 3d model (i.e) .obj file. how can i read this model in matlab

is there any comment please give me

actually i am hiding the text in that 3d model

please help me.

here i attach that (.obj) file please see it.

then one impotent thing this file have v=>vertex and f=>face number here i will hide the data.


Not open for further replies.

Part and Inventory Search

Welcome to