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

2 views (last 30 days)
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 Comments
Alan Weiss
Alan Weiss on 17 Aug 2015
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 on 17 Aug 2015
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.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!