Plotting a curve using two interdependent intervals
9 views (last 30 days)
Show older comments
Hello,
I am trying to plot the braking distance graph for a vehicle braking where the speed "v" ranges from 0 to 373 km/h and the real friction coefficient "ux" is a function of the standing grip coefficient "u" and decays by 10% with each 110 km/h of speed gained. The other values are constants, "t"=total reaction time, "a"=slope angle [rad], "p"=atmospheric pressure, "cx"=longitudinal drag coeff., "cz"=vertical drag coeff. (in this case downforce), "ax"=frontal area in square metres, 'm'=vehicle mass in kg.
This code also computes the mean deceleration as well as braking times with/without accounting for t.
This is the working code for computing the braking distance under a non-variable grip coefficient:
v=0:373; td=0.5; ts=0.2; g=9.81; a=0; p=1.204;
cx=0.35; cz=-0.05; ax=1.77; m=1240; u=1.2;
t=td+ts;
vmax=373/3.6;
w=m*g;
c0=(u*cos(a))+sin(a);
c2=p*ax*(cx-u*cz)/(w*2);
s=(log(1+((v/3.6).^2)*(c2/c0)))/(2*c2*g);
S=(log(1+((v/3.6).^2)*(c2/c0)))/(2*c2*g)+t*(v/3.6);
d=g*(c0+c2*(vmax.^2))
dG=d/g
BD=(log(1+((vmax).^2)*(c2/c0)))/(2*c2*g)
TBD=BD+t*vmax
ts=vmax/d
Ts=t+ts
hold on, grid on
plot (v,s, 'r'); plot (v,S, 'k')
However the script accounting for ux cannot be represented in the same way:
ux=u*(1-(3.6*(v/3.6)/1100));
c0x=(ux*cos(a))+sin(a);
c2x=p*ax*(cx-ux*cz)/(w*2);
sx=(log(1+((v/3.6).^2)*(c2x/c0x)))/(2*c2x*g);
Sx=(log(1+((v/3.6).^2)*(c2x/c0x)))/(2*c2x*g)+t*(v/3.6);
dx=g*(c0x+c2x*(vmax.^2))
dGx=dx/g
BDx=(log(1+((vmax).^2)*(c2x/c0x)))/(2*c2x*g)
TBDx=BDx+t*vmax
tsx=vmax/dx
Tsx=t+tsx
hold on, grid on
plot (v,sx, 'm'); plot (v,S, 'b')
MATLAB prompts the following script: "Error using / Matrix dimensions must agree."
I'd be grateful if anyone would be kind enough to help me out with plotting this function. Thank you in advance!
0 Comments
Answers (1)
Chunru
on 1 Dec 2023
You need array division ./ instead of /
v=0:373; td=0.5; ts=0.2; g=9.81; a=0; p=1.204;
cx=0.35; cz=-0.05; ax=1.77; m=1240; u=1.2;
t=td+ts;
vmax=373/3.6;
w=m*g;
c0=(u*cos(a))+sin(a);
c2=p*ax*(cx-u*cz)/(w*2);
s=(log(1+((v/3.6).^2)*(c2/c0)))/(2*c2*g);
S=(log(1+((v/3.6).^2)*(c2/c0)))/(2*c2*g)+t*(v/3.6);
d=g*(c0+c2*(vmax.^2))
dG=d/g
BD=(log(1+((vmax).^2)*(c2/c0)))/(2*c2*g)
TBD=BD+t*vmax
ts=vmax/d
Ts=t+ts
hold on, grid on
plot (v,s, 'r'); plot (v,S, 'k')
ux=u*(1-(3.6*(v/3.6)/1100));
c0x=(ux*cos(a))+sin(a);
c2x=p*ax*(cx-ux*cz)/(w*2);
sx=(log(1+((v/3.6).^2)*(c2x/c0x)))/(2*c2x*g);
Sx=(log(1+((v/3.6).^2)*(c2x/c0x)))/(2*c2x*g)+t*(v/3.6);
dx=g*(c0x+c2x*(vmax.^2))
dGx=dx/g
%whos
BDx=(log(1+((vmax).^2)*(c2x./c0x)))./(2*c2x*g) %<=============
TBDx=BDx+t*vmax
tsx=vmax./dx %<=============
Tsx=t+tsx
hold on, grid on
plot (v,sx, 'm'); plot (v,S, 'b')
0 Comments
See Also
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!