Optimization problem with multivariable functions
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey!
I try to optimize a function with syms but get an error. Im new to syms but wanted to try and learn. The code i been written is:
% Testing_syms_functions
clc
D=1; S=1;L=1;q=1;
syms x a1 a2 b2 b3 b4
ws(x, a1, a2, b2, b3, b4) = a1*x + a2*x^2;
wb(x, a1, a2, b2, b3, b4) = b2*x^2 + b3*x^3 + b4*x^4;
dwsx=diff(ws,x,1);
d2wbx=diff(wb,x,2);
U1 = 0.5*int((D*(d2wbx)^2 + S*(dwsx)^2),0,L) ;
U2 = -int(q*(ws+wb),0,L);
E = U1 + U2;
dEa1=diff(E,a1,1);
dEa2=diff(E,a2,1);
dEb2=diff(E,b2,1);
dEb3=diff(E,b3,1);
dEb4=diff(E,b4,1);
dE=[dEa1 dEa2 dEb2 dEb3 dEb4];
H=[diff(dEa1,a1,1), diff(dEa2,a1,1), diff(dEb2,a1,1), diff(dEb3,a1,1), diff(dEb4,a1,1);
diff(dEa2,a1,1), diff(dEa2,a2,1) diff(dEb2,a2,1), diff(dEb3,a2,1), diff(dEb4,a2,1);
diff(dEb2,a1,1), diff(dEb2,a2,1), diff(dEb2,b2,1), diff(dEb2,b3,1),diff(dEb2,b4,1);
diff(dEb3,a1,1), diff(dEb3,a2,1), diff(dEb3,b2,1), diff(dEb3,b3,1), diff(dEb3,b4,1);
diff(dEb4,a1,1), diff(dEb4,a2,1), diff(dEb4,b2,1), diff(dEb4,b3,1), diff(dEb4,b4,1);];
c=[2; 1; 1; 1; 1];
kmax=10; tol=0.5e-8;
for k=1:kmax
d=-H\dE(c);
c=c+d;
disp([c' norm(d)])
if norm(d)<tol, break, end
end
Now i get an error saying:
Error using symfun/subsref (line 172)
Symbolic function expected 5 input arguments but received 1.
Error in Testing_syms_functions (line 41)
d=-H\dE(c);
Can someone please help me?
BR
Daniel
1 comentario
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!