Why doesn't my code work correctly?
이전 댓글 표시
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';
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!