how to plot displacement vs time for a vehicle of altering motion PLZ help (
Show older comments
VEHICLE 2
Im trying to plot the displacement of a vehicle for t=0 to t=23 in steps of 0.1
The vehicle has constant velocity of (-20 m/s) for t=0 to t=1 from t=1 to t=6 (total of 5 seconds) it slows down with constant acceleration of (-2),
from t=6 to t=23 its velocity is constant at (-10 m/s)
here is my code, when i try to plot it its stupid and doesnt make sense please
clear all
S=300; %spam of the bridge in m
x0=[0 -5 -15 210 215 225 325 330 395 400]; %initial 'x' positions of vehicles axels (Front,Middle,Rear) (m) v0=[15 15 15 -20 -20 -20 25 25 20 20]; %initial velocity of each axel (m/s) w =[60000 40000 100000 60000 40000 100000 10500 24500 10500 24500]; %load on each axel (N)
s_step = 0.5; t_step = 0.1;
y = [0:s_step:S]; t = [0:t_step:23]; [Y,T] = meshgrid (y,t);
T1 = T(1:231,:); % 0 to 23 seconds T2 = T(1:11,:) ; % 0 to 1 seconds T3 = T(12:61,:); % 1 to 6 seconds T4 = T(13:231,:); %6 to 23 seconds
%Positions of axels of vehicle 1
for i = 1
X1f(1:231,:) = x0(i) + v0(i)*T1; %position function of front axel of
X1m=X1f-5;
X1r=X1m-10;
end
%Position of axels of vehicle 2
for i= 4 X2f(1:11,:) = x0(i) + v0(i)*T2; %colum 1 to 11 of X2f.... X2f(12:61,:) = (x0(i)-20)+0.5*(-2)*(T3-1).^2 X2f(13:231,:)= v0(i)*(T4);
X2m=X2f+5;
X2r=X2m+10;
end
plot (T,X2f)
I CANT FIND THE ISSUE!
Answers (0)
Categories
Find more on Automated Driving Toolbox 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!