zufryy
zufryy

Reputation: 187

How to get first derivation of equation in matlab

I have this equation: f(a,b,x)=t0-a+(a^2*(1+((x-x0)^2/b^2)))^0.5

if I want get the first derivative: df(a,b,x)/d(a,b) for x0,t0 = constant and a,b,x = array.

is this true if I use this script

> syms f; syms t0; syms x; syms x0; syms
> a; syms b;
> 
> 
> f=t0-a+(a^2*(1+((x-x0)^2/b^2)))^0.5;
> f_1=diff(f,a)+diff(f,b)

I'm asking because I never get the right plot if I use this method... Any suggestions?

Upvotes: 1

Views: 724

Answers (1)

Jonas
Jonas

Reputation: 74940

df/d(a,b) is not equal df/da+df/db. Rather, it is (df/da)/db.

In other words, you need to write

f_1=diff(diff(f,a),b);

Upvotes: 1

Related Questions