error :too many output in using ga toolbox

Hello, I am trying to use the ga function to obtain the value of two parameters in order to maximize one of ODE45 outputs (I have 5 ODEs solved by ODE45) and I am running the code below.The problem is that when I try to use the Optimization Tool, I always get the 'Too many output arguments' error message.
function fit = objf(P)
[t,y]= ode45(@(t,y)systemEQf,0:0.1:30,[0 0 0 0 -1.9]);
fit = y(:,4)
end
and systemEQf.ma
function dy = systemEQf(t,y)
global dsw V Nb eps rosw H D viscsw velosw Tsat;
global deltaH Prsw C0 condsw Cps Cpw S roi ex Lc beta ;
global alfa Cpsw a a2 K2 c1 c2 PI;
%Données geométriques
V= 0.000387;%m3
S= 135.5; %m-1
H= 0.4;%m
D= 0.05;%m
Nb= 2;
% Données caractéristiques de l'eau de mer
rosw=1028.11; %kg/m3
viscsw=0.000001826;
velosw=1449;%m/s
deltaH= 334700; %j/kg
roi=917;%kg/m3
Prsw=13.4;
C0=0.035;
condsw=0.563;%j/m.k.s
Cps=880;%j/kg.k
Cpw=4182;%j/kg.k
Tsat= -1.9;%k
% Données cinétiques
ex = 17;
Lc = 0.000005;%m
beta = 0.000003; % m s-1 K-1
alfa = 10^8; % s-1m-2K-
eps = 5; %m-1
%Point de fonctionnement
%Vscrap = 47.12;%rad/s
dsw = 0.014;%kg/s 25/50/75
%Trf= -6; %k
% Constantes
PI= 3.14;
c1= 0.5874;
c2=0.2599;
% Calcul des parametres et constantes
Cpsw =(C0*Cps)+((1-C0)*Cpw); %j/kg.k
%he=(condsw*rosw*Cpsw*Vscrap*Nb/15*PI)^(0.5);%j/m2.k.s
a=1/(rosw*Cpsw);% k.m3/j
a2=a*deltaH*roi; %k
%K1= a*S*he;
K2= a2*PI/6;%k
dy(1) = ((alfa*D*PI*(Tsat-Trf)^2)/V) + (eps*Vscrap*y(2));
dy(2) = (( beta*(Tsat-y(5)))*y(1))+ (((alfa*D*PI*(Tsat-Trf)^2)/V)*Lc) +...
(c1*eps*Vscrap*y(3));
dy(3) = (2*( beta*(Tsat-y(5)))*y(2))+ (((alfa*D*PI*(Tsat-Trf)^2)/V)*Lc*Lc)...
+ (c2*eps*Vscrap*y(4));
dy(4) = (PI/6 )*((3*( beta*(Tsat-y(5)))*y(3))+ ...
(((alfa*D*PI*(Tsat-Trf)^2)/V)*Lc*Lc*Lc));
dy(5) = (a*S*((condsw*rosw*Cpsw*Vscrap*Nb/15*PI)^(0.5))*(Trf-y(5)))+...
(a*(viscsw*(1+(2.5*y(4))+(10.05*y(4)^2)+(2.73*0.001*exp(16.6*y(4))))*...
(2*PI*ex*Vscrap)^2))+(K2*(3*( beta*(Tsat-y(5)))*y(3)+ ...
((alfa*D*PI*(Tsat-Trf)^2)/V)*Lc*Lc*Lc));
dy= dy(:)
end

4 Comments

the 2 parameters are Trf varied between -10 and-6 and Vscrap varied between 25 and 75
You didn't show your ga call. It would help us to see it. Also, what happens when you try to evaluate f = objf(P) for some particular value of P? What size is the output, f?
Alan Weiss
MATLAB mathematical toolbox documentation
I USE GA with toolbox in matlab with the 2 parametres when i solved the ODEs with ODE45 for some particular value of the two parametrers it works and a i have a good response the problem is to use the ODE45 output as ga fitness function and find the optimal parameters of
I have changed My code th new one is
function yr = fit_systemEQf(p)
[t,ys]=ode45(@systemEQf,[0 30],[0 0 0 0 -1.9])
yr= ys( :,4);
end
but when i use ga toolbox i get the error below
Optimization running. Error running optimization. Too many output arguments. please help me to solve the problem

Sign in to comment.

Answers (0)

Categories

Asked:

on 8 May 2018

Community Treasure Hunt

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

Start Hunting!