Create Mfile to find distance velocity and acceleration dist
Create M-file to find distance, velocity and acceleration. distance = t^3/12 velocity = t^2/4 acceleration = 0.5t Use input command in the script and ask a question to the user: please enter the time vector in the command window. After you press run button, command window will be shown. Enter a time vector starting from 0 to 50 seconds with an increment of 0.5 seconds from the command window. In the main script, plot t versus distance, t versus velocity and t versus acceleration using subplot and plot command. Give appropriate title, x label and y label. Save \'t\' and \'velocity\' in table. Make sure \'t\' and \'velocity\' are row vectors and table first row is \'t\' and second row is \'velocity\'. Use disp command to display column names \'time, s velocity, m\'. Use fprintf command to display table in command windo. Please refer to question 2 script for guidance.
Solution
t_input = input(\'Please enter the time vector in the command window: \');
distance = [];
velocity = [];
acceleration = [];
for t = t_input
[d, v, a] = output(t);
distance(end+1) = d;
velocity(end+1) = v;
acceleration(end+1) = a;
end
figure
subplot(2, 2, 1)
plot(t_input, distance)
title(\'Time v/s Distance\')
subplot(2, 2, 2)
plot(t_input, velocity)
title(\'Time v/s Velocity\')
subplot(2, 2, 3)
plot(t_input, accleration)
title(\'Time v/s Acceleration\')
Table = table(t_input, velocity);
writetable(Table);
disp(\'time, s velocity, m\');
fprintf(\'%3f %5f \ \', t_input, velocity);
