Want to find out value of x1,x2,x3,x4,x5 with GA optimization toolbox. How to do it?

6 次查看(过去 30 天)
cos(x1)+cos(x2)+cos(x3)+cos(x4)+cos(x5)=0.9;;
cos(5(x1))+cos(5(x2))+cos(5(x3))+cos(5(x4))+cos(5(x5))=0;;
cos(7(x1)))+cos(7(x2))+cos(7(x3))+cos(7(x4))+cos(7(x5))=0;;
cos(11(x1))+cos(11(x2))+cos(11(x3))+cos(11(x4))+cos(11(x5))=0;;
cos(13(x1))+cos(13(x2))+cos(13(x3))+cos(13(x4))+cos(13(x5))=0;;
0<x1<x2<x3<x4<x5<90degree;;
I have done some programming. But it has some error. I can not understand it.
function z = gener (x)
A=[1 5 7 11 13;1 5 7 11 13;1 5 7 11 13;1 5 7 11 13;1 5 7 11 13];
rhs=[0.9 0 0 0 0].';
z=sum( cos( A*diag(x(:) )) ,2) - rhs;
end
Please tell me how I will get output ?
  2 个评论
Alan Weiss
Alan Weiss 2015-8-17
I cannot see what you have dne and what you are trying to get. Please format your code with the {} Code button. And please check the documentation for how to write a fitness function.
Alan Weiss
MATLAB mathematical toolbox documentation
Walter Roberson
Walter Roberson 2015-8-17
Please show your code that calls ga, and please show the error message.
Also remember that cos() expects radians so use cosd() if you want degrees.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by