Thread Subject: symbolic toolbox

Subject: symbolic toolbox

From: Steve

Date: 12 Oct, 2007 00:51:38

Message: 1 of 4

How do you specify what variables are functions of, say
time? I can't find it in the manual. So, for example, if I
type

syms x
f=x
diff(x)

The solutions is 1. But what if x is a function of t? Then
the solution will be d/dt(x).

Thanks in advance

Subject: symbolic toolbox

From: Steven Lord

Date: 12 Oct, 2007 03:21:23

Message: 2 of 4


"Steve " <steveDEL.bachmeierDEL@yahoo.com> wrote in message
news:femgeq$3f7$1@ginger.mathworks.com...
> How do you specify what variables are functions of, say
> time? I can't find it in the manual. So, for example, if I
> type
>
> syms x
> f=x
> diff(x)
>
> The solutions is 1. But what if x is a function of t? Then
> the solution will be d/dt(x).

syms t
x = sym('x(t)')
dx = diff(x, t)
dx_tsquared = simplify(subs(dx, x, t^2))

--
Steve Lord
slord@mathworks.com

Subject: symbolic toolbox diff

From: Dan Marghitu

Date: 10 Nov, 2007 22:34:49

Message: 3 of 4

How do you take the derivative of a variable function of time?
For example

syms t
x = sym('x(t)')
f = 2*x

I want to take the derivative of function f with respect to ‘x(t)’
diff(f, x) or diff(f, 'x(t)')

Subject: symbolic toolbox diff

From: Ben Hinkle

Date: 12 Nov, 2007 15:09:40

Message: 4 of 4

"Dan Marghitu" <marghitu@auburn.edu> wrote in message
<fh5bm8$84u$1@fred.mathworks.com>...
> How do you take the derivative of a variable function of time?
> For example
>
> syms t
> x = sym('x(t)')
> f = 2*x
>
> I want to take the derivative of function f with respect
to ‘x(t)’
> diff(f, x) or diff(f, 'x(t)')

If you want to sometimes treat x as a function of t and
sometimes not then you can define two variables xt =
sym('x(t)') and x = sym('x') and substitute one for the
other when you want to. For example f = 2*x treats f as a
function of x while ft = 2*xt treats f as a function of t.
Then diff(ft) is 2*diff(x(t),t). If you have an expression g
which involves x then you can use subs(g,x,xt) to replace x
with x(t). Similarly you can replace x(t) with x.

Hope that helps,
-Ben

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
symbolic solver Steve 11 Oct, 2007 20:55:05
calculus Steve 11 Oct, 2007 20:55:05
diff Steve 11 Oct, 2007 20:55:04
symbolic toolbox Steve 11 Oct, 2007 20:55:04
rssFeed for this Thread

Contact us at files@mathworks.com