Error with function derivative.
조회 수: 18 (최근 30일)
이전 댓글 표시
I have the following function
miu=0.1;
u=[1 1 1 1 1 1];
niu=u(6);
Syms x1,x2
FunctionP=@(x1,x2)(x1^4-2*x1^2*x2+x1^2-2*x1+4)+...
miu*((max((0.25*x1^2-0.75*x2^2-1+u(1)/2*miu),0)^2)+(max((-x1+u(2)/2*miu),0)^2)+...
(max((x1-5+u(3)/2*miu),0)^2)+(max((-x2+u(4)/2*miu),0)^2)+(max((x2-5+u(5)/2*miu),0)^2))...
-(((u(1)^2)/(4*miu))+((u(2)^2)/(4*miu))+((u(3)^2)/(4*miu))+((u(4)^2)/(4*miu))+((u(5)^2)/(4*miu)))...
+niu*(2*x1^2+x2^2-2)+miu*(2*x1^2+x2^2-2)^2;
FunctionDiff_x1 = diff(FunctionP,x1);
FunctionDiff_x2 = diff(FunctionP,x2);
x=[0,3];
x1=x(1);
x2=x(2);
t=eval(FunctionDiff_x1);
I obtain the following error:
??? Error: ()-indexing must appear last in an index expression.
Error in ==> sym.eval at 15 s = evalin('caller',vectorize(map2mat(char(x))));
Error in ==> Problem3b at 61 t=eval(FunctionDiff_x1);
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!