This is the following code has an error as :
" Error using sym/diff (line 69)
The second argument must be a variable or a nonnegative integer specifying the number of differentiations.
Error in quiz21 (line 36)
J(j,1)=diff(g,var(j));
"
The code is given below :
function var1= quiz21()
syms x1 x2 x3 x4 lm
var=[ x1 x2 x3 x4 ]';
f(1,1) = (x4)^3 - (204 +2.4*x2 + 0.02*x2*x1 - 1.5*x1) ;
f(2,1) = x3 - 1.2*(x4)^2 ;
f(3,1) = x4 - ( -5 - x2 )*10*( 1 - exp(-7.621/10)) ;
f(4,1) = x3 - ( x1 - 30 )*19.2*( 1 - exp(-13.31/19.2)) ;
numeq=length(f);
J = sym('A',[numeq 1]);
p = 10;
g= (f(1,1)- p*( f(2,1) + f(3,1) + f(4,1)));
disp(g);
for j=1:numeq
J(j,1)=diff(g,var(j));
end
disp(J)
0 Comments
Sign in to comment.