How to write a mathematical function in MATLAB?

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.

3 comentarios

Rik
Rik el 4 de Nov. de 2020
What did you try? Have a read here and here. It will greatly improve your chances of getting an answer.
Swati Sarangi
Swati Sarangi el 5 de Nov. de 2020
Hello Rik,
I got the idea for my doubt. Along with that I want to display the vector V as a whole whose individual components are inputted by the users.
This is my code snippet.
m=input("Enter the mass of the particle")
V_x=input("Enter the x component of velocity of the particle,(V_x i)")
V_y=input("Enter the y component of velocity of the particle, (V_y j)")
V_z=input("Enter the z component of velocity of the particle ,(V_z k)")
disp("The velocity vector of the particle is %f i+ %f j+%f k ") ----> In this line , which format specifier shold I use to display vector V as a whole (with its individual componenets)
Thanks! :)
Swati Sarangi
Swati Sarangi el 5 de Nov. de 2020
Yeah, I got what I was looking for
disp("The velocity vector of the particle is")
disp(V_x*i+V_y*j+V_z*k)

Iniciar sesión para comentar.

 Respuesta aceptada

VBBV
VBBV el 4 de Nov. de 2020
Editada: VBBV el 4 de Nov. de 2020
%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

1 comentario

no the i^ and so on indicate different unit vectors along different axes.
You probably need to introduce new symbolic variables to stand in for the components, and add logic to handle raising them to various powers using mapSymType.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 4 de Nov. de 2020

Comentada:

el 5 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by