genetic algorithm- need help
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
i am not able to estimate the parameters using optimisation(solver GA) toolbox.
function error= work(k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11)
load coalinput1;
load wa1;
load toh;
load pmillh1;
for i=1:30
mc(s)=coalinput1/(k1*(1/k1)*s+1);
mpf(s= k1*mc/(k2*50)*(s/k2*50+1);
pmill(s)=k3*mc(s)+k4*mpf+k6*50/(k5*((s/k5)+1));
to(s)=((k7*250+k8)*wa1)+ k9*coalinput1- (k11*wa1+ k11*coalinput1)/((wa1*k10+coalinput1*k10)*((S/wa1*k10+coalinput1*k10)+1));
error=0.5*(to(s)-toh).^2+ 0.5*(pmill(s)-pmillh1).^2;
end
end
All the loaded inputs are of 61X2 double type
Error is Matrix dimensions must agree.
0 个评论
回答(1 个)
In Matlab, when you have two matrices, say A of size 3 * 4, and B of size 4 * 12, if you multiply A*B the result will be a matrix of size 3*12. You cannot multiply two matrices which have not the same size along one of their dimensions, and the order in which you multiply them matters. It seems to me that what you want to do is to multiply element by element. If you want to do that then:
k11*coalinput1
should be written as:
k11.*coalinput1
The dot is important, it indicates multiplication element by element. Same goes for the power: A.^2 squares every element in A. A^2 squares the matrix. Same rules apply for the division.
Cheers!
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!