Why doesn't my code work correctly?
Mostrar comentarios más antiguos
Hi
c0 must be numeric, but my symbolic functions can not work correctly?
Where is my mistake?
Thx
clear all
clc
syms x1 x2
F=x1^2+x2^2-4*x1-2*x1*x2;
gradx1=gradient(F,x1);
gradx2=gradient(F,x2);
c=[gradx1; gradx2];
fun_x0=@(x1,x2) F;
fun_c1_x0=@(x1,x2) gradx1;
fun_c2_x0=@(x1,x2) gradx2;
x0=[1,1];
c_x0_1=fun_c1_x0(x0(1),x0(2));
c_x0_2= fun_c2_x0(x0(1),x0(2));
c0=[c_x0_1; c_x0_2];
c0=c0';
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!