Borrar filtros
Borrar filtros

How can i solve this function below ?

2 visualizaciones (últimos 30 días)
Mallouli Marwa
Mallouli Marwa el 29 de Mzo. de 2016
Comentada: Gokul Prassad S el 8 de Mzo. de 2019
To solve a second order differential equation : dx/dt = Ax + Bu(t) I use this function but i haven't obtain any result :
function xdot = msd(t,x)
% Function file for mass with spring and damping.
% Position is first variable, velocity is second variable.
u = 10;
m = 1;c = 2;k = 5;
A = [0, 1;-k/m, -c/m];
B = [0; 1/m];
xdot = A*x+B*u;
[t, x] = ode45(@msd, [0,5], [0,0];

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 29 de Mzo. de 2016
Editada: Azzi Abdelmalek el 29 de Mzo. de 2016
Save the function below as msd.m
function xdot = msd(t,x)
% Function file for mass with spring and damping.
% Position is first variable, velocity is second variable.
u = 10;
m = 1;c = 2;k = 5;
A = [0, 1;-k/m, -c/m];
B = [0; 1/m];
xdot = A*x+B*u;
then in Matlab Windows Command write
[t, x] = ode45(@msd, [0,5], [0,0]);
plot(t,x)
  3 comentarios
Torsten
Torsten el 30 de Mzo. de 2016
Use
[t, x] = ode45(@msd, [0,5], [0;0]);
Best wishes
Torsten.
Gokul Prassad S
Gokul Prassad S el 8 de Mzo. de 2019
it was very useful Mr. Torsten. Can you please explain
[t, x] = ode45(@msd, [0,5], [0;0]);
I want to understand the reason behind using this code.
Kindly help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Assembly en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by