Azzera filtri
Azzera filtri

Error with function derivative.

1 visualizzazione (ultimi 30 giorni)
emanuele teodori
emanuele teodori il 18 Nov 2014
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);

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by