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

 채택된 답변

Torsten
Torsten 2014년 11월 20일

0 개 추천

It is not possible simply to output (VI,Vw) given (TL,TR).
As input you need (VIold,Vwold,Vwdotold,dt,TL,TR).
The output VI,Vw and Vwdot is then calculated according to
VI=VIold+dt*(TL+TR)/(M*r)
Vw=Vwold+dt*Vwdotold
Vwdot=Vwdotold+dt*L*(TL-TR)/(2*r*I).
This would mean that your function "Modelfun" advances VI and Vw from their values at time t to time t+dt.
Best wishes
Torsten.

추가 답변 (2개)

Torsten
Torsten 2014년 11월 18일

0 개 추천

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

Maria
Maria 2014년 11월 18일
thanks a lot but please could you explain how and why did you that ?
hint : the equations are for dynamic model of mobile robot
Maria
Maria 2014년 11월 19일
Any help ? please
Torsten
Torsten 2014년 11월 19일
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
Maria 2014년 11월 19일
thanks a lot Torsten
Actually , I am not so good with Matlab and from my little bit understanding I built this function and I don't know if that right but generally what I want to do is to write the equations above in code form inside "Embedded MATLAB Function " block with two inputs(TL,TR) and two outputs (VI,Vw) as in figure above.
thanks
Maria
Maria 2014년 11월 20일
???

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

질문:

2014년 11월 18일

답변:

2020년 2월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by