Questian about optmization errror.
Afficher commentaires plus anciens
Look to my trying optm..plz someone help me
Its the Wrong messenger that appears....
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.
Error in ==> nonlin at 2
c = [atan(deg2rad((x(9)-x(10))/(x(11)-x(12))))-atan(deg2rad((x(4)-x(2))/(x(8)- x(6)))) - deg2rad(3);
Error in ==> fmincon at 654
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Caused by:
Failure in initial user-supplied nonlinear constraint function evaluation. FMINCON cannot continue.
Ive made 3 .m files...they are...
function f = suspension(x)
f = (((x(3)-x(1))+(x(5)/((x(6)-x(5))/(x(2)-x(1))))-...
(x(7)/((x(8)-x(7))/(x(4)-x(3)))))/((1/((x(6)-x(5))/(x(2)-x(1))))-...
(1/((x(8)-x(7))/(x(4)-x(3))))))*(1+((((x(7)-x(5)+...
(((x(6)-x(5))/(x(2)-x(1)))*x(1))-(((x(8)-x(7))/(x(4)-...
x(3)))*x(3)))/(((x(6)-x(5))/(x(2)-x(1)))-...
((x(8)-x(7))/(x(4)-x(3)))))/(((x(2)+x(4))/2)+(x(9)/2)-...
((x(7)-x(5)+(((x(6)-x(5))/(x(2)-x(1)))*x(1))-...
(((x(8)-x(7))/(x(4)-x(3)))*x(3)))/(((x(6)-x(5))/(x(2)-x(1)))-...
((x(8)-x(7))/(x(4)-x(3)))))))));
function [c,ceq] = nonlin(x)
c = [atan(deg2rad((x(9)-x(10))/(x(11)-x(12))))-...
atan(deg2rad((x(4)-x(2))/(x(8)-x(6)))) - deg2rad(3);
atan(deg2rad((x(13)-x(14))/(x(16)-x(15))))-...
atan(deg2rad((x(4)-x(2))/(x(8)-x(6)))) - deg2rad(3);
1/2*(x(10) + x(9) - x(2) - x(4)) +3.5*(1-cos(deg2rad(3)))-...
10.5*(sin(deg2rad(3))) - 1.2;
1/2*(x(14) + x(13) - x(2) - x(4)) +3.5*(1-cos(deg2rad(3)))-...
10.5*(sin(deg2rad(3))) - 2;];
ceq = [(sqrt(((x(2)-x(1))^2)+((x(6)-x(5))^2)))-...
(sqrt(((x(10)-x(1))^2)-((x(12)-x(5))^2)));
(sqrt(((x(2)-x(1))^2)+((x(6)-x(5))^2)))-...
(sqrt(((x(14)-x(1))^2)-((x(15)-x(5))^2)));
(sqrt(((x(4)-x(3))^2)+((x(8)-x(7))^2)))-...
(sqrt(((x(9)-x(3))^2)-((x(11)-x(7))^2)));
(sqrt(((x(4)-x(3))^2)+((x(8)-x(7))^2)))-...
(sqrt(((x(13)-x(3))^2)-((x(16)-x(7))^2)));
(sqrt(((x(2)-x(4))^2)+((x(6)-x(8))^2)))-...
(sqrt(((x(10)-x(9))^2)-((x(12)-x(11))^2)));
(sqrt(((x(2)-x(4))^2)+((x(6)-x(8))^2)))-...
(sqrt(((x(14)-x(13))^2)-((x(15)-x(16))^2)));];
and...
%%igualdades lineares - suspensão
Aeq = zeros(6,16); beq = [4;-4;10;15;6;10.5] ;
Aeq(1,[12,6]) = [1,-1];
Aeq(2,[15,6]) = [1, -1];
Aeq(3,7) = 1;
Aeq(4,5) = 1;
Aeq(5,3) = 1;
Aeq(6,1) = 1;
%%desigualdades lineares
A = zeros(1,16); b = zeros(1,1);
A(1,[2,4]) = [1,-1];
%%inicio
x0 = [10.5,23.5,6,24.5,15,15,10,8,24.1,23.1,12,19,23.67,22.67,11,4];
I call the function like this
options = optimset('Algorithm','sqp');
[x,fval] = fmincon(@suspension,x0,A,b,Aeq,beq,[],[],@nonlin,options)
plz..could someone help me?
Réponses (1)
Wayne King
le 22 Sep 2012
First clear c if it's in your workspace and try this.
c = [atan(deg2rad((x(9)-x(10))/(x(11)-x(12))))-...
atan(deg2rad((x(4)-x(2))/(x(8)-x(6)))) - deg2rad(3);
atan(deg2rad((x(13)-x(14))/(x(16)-x(15))))-...
atan(deg2rad((x(4)-x(2))/(x(8)-x(6)))) - deg2rad(3);
1/2*(x(10)+ x(9)-x(2)-x(4))+3.5*(1-cos(deg2rad(3)))-...
10.5*(sin(deg2rad(3))) - 1.2;
1/2*(x(14) + x(13)-x(2)- x(4))+3.5*(1-cos(deg2rad(3)))-...
10.5*(sin(deg2rad(3))) - 2];
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!