Help is needed! I have a problem with symbolic derivative expression by Matlab. I work with Hill equation. When I evaluate the symbolic expression of its first derivative, I found out the value isn't quite correct. I diff() with respect to the correct variable, vectorize the expression (If calculated correctly, c=10 should correspond to half amplitude, also c=10 is where the derivative is at max). I don't know what else is there to be done. The following code is what I have done:
%Hill's equation
%
% c Independent variable.
% q Hill's coefficient.
% s^q Halfsaturation term.
% Y Amplitude
% Y = (c^q)/(c^q + s^q) This is the pseudocode for Hill equation
clear all;
c=(0:1:100)';
q=2;
s=10;
y = (c.^(q))./((c.^q)+s^q);
dy_dx = y./c; %Calculate slope at every point. This is gives correct result.
dy_dx_symtb = c.^q.*q./c./(c.^q+s.^q)(c.^q).^2./(c.^q+s.^q).^2.*q./c;
%This is generated by Matlab symbolic toolbox
% by the following commands: ans=diff(y, c); vectorize(ans).
%Plot results
figure(1); subplot(211); plot(c, y); xlabel('c'); ylabel('y'); legend('Hill coefficient = 2');
figure(1); subplot(212); plot(c, dy_dx, c, dy_dx_symtb); xlabel('c'); ylabel('y'); legend('calculated dy/dx is correct', 'evaluating symbolically derived dy/dx');
