Equations to Matlab code
Mostrar comentarios más antiguos
hi
I want to convert the two equations below into Matlab code , I wrote the function below for that and I don't know if that is correct or not , specially the integral form ? any help ?

function [VI,Vw]= Modelfun(TL,TR)
dt=0.01; %sampling time
r=0.052;
L=0.306;
M=9;
I=5;
VI=(TL+TR)/ M * r;
VI=VI*dt/2; %first integral
Vw=(L*(TL-TR)) / 2 * r * I;
Vw=Vw*dt/2; %first integral
Vw=Vw*dt/2; %second integral
end
Respuesta aceptada
Más respuestas (2)
Torsten
el 18 de Nov. de 2014
0 votos
If the right-hand sides of your equations does not depend on t, the solution to your differential equations is explicitely given by
VI=VI0+(TL+TR)/(M*r)*t
Vw=Vw0+Vw0dot*t+0.5*L*(TL-TR)/(2*r*I)*t^2
where
VI0=VI at time t=0
Vw0=Vw at time t=0
Vw0dot = d/dt(Vw) at time t=0.
Best wishes
Torsten.
5 comentarios
Maria
el 18 de Nov. de 2014
Maria
el 19 de Nov. de 2014
Torsten
el 19 de Nov. de 2014
What is your function "Modelfun" supposed to do ?
Should it calculate VI(t+dt) and Vw(t+dt) given the values VI(t) and Vw(t) ?
Best wishes
Torsten.
Maria
el 19 de Nov. de 2014
Maria
el 20 de Nov. de 2014
Warren Dennis
el 17 de Feb. de 2020
0 votos
k=k0e

Categorías
Más información sobre Numerical Integration and Differentiation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
