MATLAB: How to write a mathematical function in MATLAB

differentiation

Hi All,
I want to write velocity vector in terms of its component in x, y and z direction , say V= V(t)_x i^+V(t)_y j^+V(t)_z k^. These components are functions of time.
Then I want to differentiate that function with respect to time.
How to do that ?
Any suggestion will be appreciated!
Thanks in advance.

Best Answer

%if true
% code
% end
syms t i j k
vx = t^2;
vy = t^3;
vz = t^4;
V = @(t) vx*i+vy*j+vz*k;
VV = diff(V,t);% differentiate
Use symbolic expressions and diff function