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?

 採用された回答

Alan Weiss
Alan Weiss 2014 年 2 月 25 日

0 投票

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 件のコメント

bhavya
bhavya 2014 年 3 月 1 日
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
Alan Weiss
Alan Weiss 2014 年 3 月 3 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2014 年 2 月 25 日

コメント済み:

2014 年 3 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by