MATLAB Answers


Parse error help please

Asked by Patrick Bradford on 25 Jul 2019
Latest activity Commented on by Patrick Bradford on 26 Jul 2019
parse error line 8. It's supposed to be the "normal force' (z) on the front left tire, x first derivative of wx. But it freaks out about the equil sign. Suggestions?
%%Equilibrium, roll
%% Inertial term for roll rotation is Jsx * first derivitive of wx.
%% Fflz is Normal Force, Front left z axis
%% sprung body roll inertia is (Js,x)
%% which differs from Whole Vehicle roll inertia, (Jx).
%% Damping forces Paralell to each spring force. Summation of Fdfl, Fdfr,Fdrl and Fdrr.
Jsx*der(wx) = (Fflz + Frlz)*w/2 - (Ffrz + Frrz)*w/2 + (Ffyv + Fry)*h;
%%Equilibrium for each axle (pitch, around roll centre):
(Fflz - (Fsfl + Fdfl))*w/2 - (Ffrz - (Fsfr + Fdfr))*w/2 + Ffy*hRCf = 0;
(Frlz - (Fsrl + Fdrl))*w/2 - (Frrz - (Fsrr + Fdrr))*w/2 + Fry*hRCr = 0;
%%Constitutive relation for tyres (Lateral tyre force model):
Ffyw = -sign(sfy)*(min((Cf/2)*abs(sfy), mu*Fflz) + min((Cf/2)*abs(sfy), mu*Ffrz));
Fry = -sign(sry)*(min((Cr/2)*abs(sry), mu*Frlz) + min((Cr/2)*abs(sry), mu*Frrz));
sfy = vfyw/vfxw;
sry = vry/vrx;
%%Constitution for springs:
der(Fsfl) = -cfw*vflz;
der(Fsfr) = -cfw*vfrz;
der(Fsrl) = -crw*vrlz;
der(Fsrr) = -crw*vrrz;
%%Constitution for dampers:
Fdfl = -dfw*vflz;
Fdfr = -dfw*vfrz;
Fdrl = -drw*vrlz;
Fdrr = -drw*vrrz;
%%Compatibility, out of road plane:
vflz = +w/2*wx;
vfrz = -w/2*wx;
vrlz = +w/2*wx;
vrrz = -w/2*wx;


Joel Handy on 25 Jul 2019
Are you using the symbolic math toolbox? I don't have any experience with that toolbox, so maybe this is valid syntax there, but if not, Jsx*der(wx) is not a valid variable name.
on 25 Jul 2019
Also with that toolbox the name is invalid.

Sign in to comment.

2 Answers

Answer by Jan
on 25 Jul 2019
Edited by Jan
on 25 Jul 2019

I guess, this line is failing:
Jsx*der(wx) = (Fflz + Frlz)*w/2 - (Ffrz + Frrz)*w/2 + (Ffyv + Fry)*h;
Yes, of course. In Matlab the = is the operator for assigning a value to a variable. The shown line is a methematical formula, but not a valid Matlab instruction. You need a variable on the left hand side of the =.
This will not work also:
(Fflz - (Fsfl + Fdfl))*w/2 - (Ffrz - (Fsfr + Fdfr))*w/2 + Ffy*hRCf = 0;
What is the meaning of tis line:
der(Fsfl) = -cfw*vflz;
It is not clear, what you try to achieve. The posted text is no Matlab code.

  1 Comment

It's my attempt at reacreating vehicle dynamics inputs for code. I think I might have to use matrix to make this work. I am a matlab noob, the code is mostly just trial and error attempts at trying to directly input math into matlab. lol

Sign in to comment.

Walter Roberson
Answer by Walter Roberson
on 26 Jul 2019
Edited by Walter Roberson
on 26 Jul 2019

eqn1 = Jsx*diff(wx, Something) == (Fflz + Frlz)*w/2 - (Ffrz + Frrz)*w/2 + (Ffyv + Fry)*h;
Where Something is the variable the derivative is to be taken with respect to.
You should look at the examples for dsolve()
I would, however, advise that often vehicle dynamics is required to be about numeric solutions rather than about closed form solutions: the equations are often too complex for closed form solutions. The symbolic toolbox can be useful in writing down the equations, to be followed by using tools such as ode2vectorfield() and odeFunction to generate functions to pass in to numeric solvers such as ode45().

  1 Comment

Thanks, I will try that!

Sign in to comment.