Changing a parameter in a differential equation according to a condition ?

1 visualización (últimos 30 días)
I am trying to change the input wheel velocities of a mobile robot according to a position condition ?
if d > 0 & d < 0.4
p.WR = 0.51;
p.WL = 0.5;
elseif d > 0.4 & d < 0.8
p.WR = 0.5;
p.WL = 0.51;
elseif d == 0.4
p.WR = 0.5;
p.WL = 0.5;
end
function dt = mydglw9(t,c,p)
x = c(1);y = c(2);th = c(3);
dx = (((p.r*p.WL)+(p.r*p.WR))/2) * cos(th);
dy = (((p.r*p.WL)+(p.r*p.WR))/2) * sin(th);
dth= ((p.r*p.WL)-(p.r*p.WR))/p.L;
dt = [dx;dy;dth];
pose = [x y th];
end
however i always get the error [ Reference to non-existent field 'WL' ], is there a way to make the solver check the condition before solving the differential equations ?

Respuesta aceptada

Star Strider
Star Strider el 14 de Mayo de 2017
What values does ‘d’* have?
Note that in this if block, if ‘d<=0’ or ‘d>=0.8’, the if block will not execute and the values within it will not be assigned.
  8 comentarios
Moustafa Aboubakr
Moustafa Aboubakr el 14 de Mayo de 2017
Thank you so much I used the beautiful mapshow function :) :) to draw the path instead of the long for loop and it worked great.
file attached for trial if u like, use mydglcallw10(1000,0,0.2,0) in command window
Star Strider
Star Strider el 14 de Mayo de 2017
As always, my pleasure!
I’ll take a look.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by