Problem 2: Uniformly accelerated linear motion problem (motion.m) A car, initial
ID: 668329 • Letter: P
Question
Problem 2: Uniformly accelerated linear motion problem (motion.m) A car, initially at rest, accelerates at a constant rate of 0.5 m/s^2 for 8 seconds. Write a function, which computes the distance traveled and velocity of the car. The input argument for the function should be time, t. For time, t=0:0.5:8, generate a table using the fprintf command, which lists the time, distance traveled, and velocity of the car. Label the columns of your table and include units. The first line of your function should be: function [dist, vel] = motion(t). Hint: Recall the equations of motion for uniform acceleration V = Vi + a delta t s = si + Vi delta t + a/2(delta t)^2 Run and debug your function to ensure that it works. (Note: A script will receive no credit.)Explanation / Answer
function[dist,vel] = motion(t)
%This function calculates distance and velocity
vel = 0.5 * t;
dist = vel * t;
fprintf('%f ', vel);
fprintf('%f ', dist);
end
fprintf('TIME(seconds) ');
fprintf('VELOCITY(meter/sec) ');
fprintf('DISTANCE(meters) ');
for a = 0:8
fprintf('%d ',a);
motion(a)
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.