Genetic algorithm toolbox

Hello all,
I am using matlab genetic algortihm tool to solve a function. I can have a result when I give numbers to my variables but genetic algorithm toolbox can not solve and gives an error message as "Subscripted assignment dimension mismatch."
But if there is any dimension mismatch on my function even it could not give the result when I solve it by giving the numbers isn't it?
I am giving my function here
%Objective Function
function [CT] = objfun(CW,D)
DEW=1000;
SS=4.74;
i=10;
L=100;
j=10;
CE=5;
DP=2;
CW(1:i,1:j)=CW;
CVM(1:i,1:j)=0;
L(1:i,1:j)=L;
D(1:i,1:j)=D;
for a=1:1:i
for b=1:1:j
CV(a,b) = CW(a,b)/(CW(a,b)+SS*(1-CW(a,b)));
DEM(a,b) = 1*(SS*CV(a,b)+(1-CV(a,b)));
CSI(a,b)=0.0039*(CV(a,b)^0.803);
if 0.3 <= CW(a,b) && CW(a,b)< 0.45;
FCW(a,b) = 0.2067*CW(a,b)+1.035;
end
if 0.45 <= CW(a,b) && CW(a,b)< 0.55;
FCW(a,b) = 1.52*CW(a,b)+0.444;
end
if 0.55 <= CW(a,b) && CW(a,b)< 0.70;
FCW(a,b) = 6.1*CW(a,b)-2.075;
end
if CW(a,b) < 0.3;
C2(a,b)=0.75;
CVM(a,b)=1.1;
end
if 0.3 <=CW(a,b) && CW(a,b)< 0.7;
C2(a,b)=2.135;
CVM(a,b)=FCW(a,b)*(DP.^0.75)*0.75*(SS^0.5);
end
if CW(a,b) > 0.7;
fprintf('No economical solution exists');
end;
CQM(a,b)=CVM(a,b)*pi/4;
C1(a,b)=CE*365*24*DEM(a,b)*CQM(a,b)*CSI(a,b)*(CVM(a,b)^1.77)*L(a,b)/101.94;
C3(a,b)= 210.89*L(a,b);
C4(a,b)= 1.3744;
C(a,b)=C1(a,b)*D(a,b)^C2(a,b)+C3(a,b)*D(a,b)^C4(a,b);
CT1= sum(C);
CT=sum(CT1,2)
end
end
end

If anyone could help me I would be very glad.
Thanks...

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion