"Wojtek" wrote in message <email@example.com>... > Hello, > in my program I want to calculate the 1st derivative of a function y (it's a function of 'x1'). Let's say I want to check if the 1st derivative of this function in some specific point is smaller then 0.05. I have: > > syms x1; > y = ( x1 - za )*( x1 - zb )*( x1 - zc )*( x1 - zd ); %my function, all the parameters like 'za' were previously declared > > dydx=diff(y,x1,1); > > x_val=1; > dydx_val=subs(dydx,x1,x_val); > k2 = solve(dydx_val); > dydx_val =double(k2); > > if (dydx_val<0.05) > remember=x_val; > end > > > unfortunately the derivative is not calculated. I get information: > Warning: 1 equations in 0 variables. > Warning: Explicit solution could not be found. > and when I try to display dydx_val i get: > > dydx_val = > >  > > I tried different methods, none of them was good (although I could do something wrong). I will be grateful for suggestions how can I calculate 1st derivative in a specific point and have the value of this derivative in double.
If I understood your question correctly, you don't need the line for solve and the following seems to work for me:
syms za zb zc zd x1; y = ( x1 - za )*( x1 - zb )*( x1 - zc )*( x1 - zd );
xVal = 1;
% Take the derivative and substitute the value of x1 focValue = subs(diff(y,'x1'),x1,xVal);