why do i get his error when using genetic algorithm for optimization?

when I run my fitness function I am gtting this error:
Subscripted assignment dimension mismatch.
this is my fitness function:
  • * __function F = ev(X)global KiKi= X;sim('gasimulink',10);F = e_out';syms tY=-Ki*int(F,t )_ * *_
what should I do to eliminate this error?

 Accepted Answer

Obviously, we cannot run your code because we do not have your function file "gasimulink" or your input X. All I can suggest at this point is that you learn how to debug in MATLAB. Set some break points and see what variables are different sizes than you expect.
Alan Weiss
MATLAB mathematical toolbox documentation

2 Comments

thanks for your reply I am an undergraduate student presently working on a project I am new to matlab and trying to learn it after reading your reply I changed my fitness function as: 'function [F] =evmat(X) global Ki Ki=X; num=[10]; den=[4 42.2 22.1 51]; c=step(num,den) syms t F=-Ki*int(c,t)' and executed in toolbox and then I got an error as: 'Error running optimization. The following error occurred converting from sym to double: Error using ==> mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a double array. If the input expression contains a symbolic variable, use the VPA function instead.' please help with this
with regards bhavya
It is hard to read your inline bold code, but it seems as if you are mixing real (double) variables and symbolic variables. The genetic algorithm wants doubles, not symbolic variables. If you need to perform an integral, convert the result back to double, or perform the numeric integral with the integral function or the quad function.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Asked:

on 25 Feb 2014

Commented:

on 3 Mar 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!