Calculate velocity from position and time
202 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kelly Harmison
am 28 Feb. 2018
Bearbeitet: alper yeldan
am 14 Sep. 2023
I have to write a program to calculate the velocity given position and time in two arrays.
0 Kommentare
Akzeptierte Antwort
KSSV
am 28 Feb. 2018
pos = rand(100,1) ;
t = 1:100 ;
v = zeros(length(t)-1,1) ;
for i = 1:length(t)-1
v(i) = (pos(i+1)-pos(i))/(t(i+1)-t(i)) ;
end
3 Kommentare
alper yeldan
am 14 Sep. 2023
Bearbeitet: alper yeldan
am 14 Sep. 2023
There is a way to solve it withouth for loop which gives the same solution.
vel = diff(pos)./diff(t);
You can compare them
pos = rand(100,1) ;
t = 1:100 ;
v = zeros(length(t)-1,1) ;
for i = 1:length(t)-1
v(i) = (pos(i+1)-pos(i))/(t(i+1)-t(i)) ;
end
vel = diff(pos)./diff(t);
figure;
hold on;
plot(t(1:end-1),v,'--r+');
plot(t(1:end-1),vel,'bo');
Weitere Antworten (1)
Arms Diether Reyes
am 6 Sep. 2021
The driver of a car wishes to pass a truck that is traveling at a constant speed of 20.0 m/s. Initially, the car is also traveling at 20.0m/s and its front bumper is 24.0 m behind the truck’s rear bumper. The car accelerates at a constant 0.0600 m/s^2, then pulls back into the truck’s lane when the rear of the car is 26.0 m ahead of the front of the truck. The car is 4.5 m long and the truck is 21.0 m long. (a) How much time is required for the car to pass the truck? (b) What distance does the car travel during this time? (c) What is the final speed of the car?
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!