Reputation: 10864
I'm sorry if I'm not formerly correct; I would like to work with symbolic functions, like i.e. x(t)
without the need to actually define x
.
This may be useful because sometimes you'll have functions of x
, and you want to calculate the derivative in t
. For example
y(x) = y(x(t)) = t*x(t)
d y(x) d x(t)
------ = x(t)+ t* ------
d t dt
Is there a way to accomplish this in matlab?
Upvotes: 3
Views: 225
Reputation: 12345
Turns out this is pretty easy (after I spent 20 minutes making it very hard).
>> y = sym('t*x(t)')
>> y_dot = diff(y,t)
y_dot =
t*diff(x(t), t) + x(t)
You can also define some intermediates if you want
>> f = sym('x(t)');
>> y = t*f;
>> diff(y,'t')
ans =
t*diff(x(t), t) + x(t)
I also discovered the mupad
command, which is worth trying out. Within the mupad window, type y(x) := t*x(t)
and diff(y(x),t)
.
Upvotes: 1
Reputation: 3935
is that ok? http://www.cs.utah.edu/~germain/PPS/Topics/Matlab/symbolic_math.html
Upvotes: 1