how to define a variable as a function of another variable in symbolic toolbox

Hi I am just wondering whether is it possible to do following: define a variable as a function of x
u=f(x)
Then,
d/dx (u*x) = u'x + xu'
u' is first derivative of u w.r.t. x.
Is this possible to do using matlab symbolic toolbox?

2 Comments

You need to set it up correctly:
syms f(x) u(x)
ddx = diff(u*f,x)
>
ddx(x) =
D(f)(x)*u(x) + f(x)*D(u)(x)

Sign in to comment.

Answers (1)

syms x u
u=cos(x)
y=u*x
out=diff(y,x)

3 Comments

Thanks for your reply. But I do not want a specific function for u. I just want to define it as a generic function of x.
You need to set it up correctly:
syms f(x) u(x)
ddx = diff(u*f,x)
>
ddx(x) =
D(f)(x)*u(x) + f(x)*D(u)(x)

Sign in to comment.

Categories

Tags

Asked:

on 5 Oct 2014

Commented:

on 6 Oct 2014

Community Treasure Hunt

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

Start Hunting!