|
Hi, Sergen. I believe that you are trying to compute your fitness
functions in a vectorized fashion, a commendable programming practice.
The error might be caused by failing to inform gamultiobj that you want
to have vectorized function evaluations. If you haven't already, try setting
options = gaoptimset('Vectorized','On');
and call gamultiobj with the options structure.
Alan Weiss
MATLAB mathematical toolbox documentation
Sergen Yalcin wrote:
> Hello,
> I am using "gamultiobj" function in Genetic algorithms toolbox. I am trying to optimize to objective functions. My m-file is as following:
>
> function f = fitness(x)
>
> w=logspace(-2,2,100);
> f = zeros(size(w,2),2); % f has dimension 100x2
>
> C=[x(1) x(2) x(3) x(4) x(5)];
> Hk=freqrespFr(C,1,w); % My own function
> H=Hk'; % H has dimension 100x1
>
> P=tf(1,[1 1]);
> Gk=freqresp(P,w);
> G=squeeze(Gk); % G has dimension 100x1
>
> f(:,1)=abs(1./(1+H.*G)); % first fitness function
> f(:,2)=abs((H.*G)./(1+(H.*G))); % second fitness function
>
> When I run this function in Genetic algorithms gui, I get error message:
> Subscripted assignment dimension mismatch.
>
> I have checked the dimension of all parameters and all seems to be correct. When I tried all commands in this m-file in Command window, it works and return correct values for f(:,1) and f(:,2).
>
> What is wrong? Can you please help me?
>
> Thanks:)
|