# Parse error help please

3 views (last 30 days)
Patrick Bradford on 25 Jul 2019
Commented: 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.
Rik on 25 Jul 2019
Also with that toolbox the name is invalid.

Jan on 25 Jul 2019
Edited: 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

Patrick Bradford on 25 Jul 2019
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

Walter Roberson on 26 Jul 2019
Edited: 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

Patrick Bradford on 26 Jul 2019
Thanks, I will try that!