Calculate velocity from position and time
104 次查看(过去 30 天)
显示 更早的评论
I have to write a program to calculate the velocity given position and time in two arrays.
0 个评论
采纳的回答
KSSV
2018-2-28
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 个评论
alper yeldan
2023-9-14
编辑:alper yeldan
2023-9-14
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');
更多回答(1 个)
Arms Diether Reyes
2021-9-6
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!