How do I get this to plot correctly?

%%
% Constant Acceleration Calculator
% Constant Velocity is = Initial Velocity + Constant Acceleration * Time
%Vi = initial velocity
%dt = delta (t) or how long are we accelerating
% ac = acceleration constant or holding the pedal down
% Vi + constant acceleration * delta(t)
Vi = input('Initial Velocity ');
dt = input('Change in time ');
ac = input('Constant acceleration ');
constant_velocity = Vi + dt * (ac);
y = linspace(-10,30);
x = constant_velocity;
hold on
plot(x,y)
grid on
fprintf('%f Meters per / Sec',y)

Answers (1)

%%
% Constant Acceleration Calculator
% Constant Velocity is = Initial Velocity + Constant Acceleration * Time
%Vi = initial velocity
%dt = delta (t) or how long are we accelerating
% ac = acceleration constant or holding the pedal down
Vi = input('Initial Velocity ');
dt = input('Change in time ');
ac = input('Constant acceleration ');
t = -10:dt:30;
constant_velocity = Vi + t * (ac);
x = constant_velocity;
hold on
plot(t, x)
grid on
% fprintf('%f Meters per / Sec',y)

This question is closed.

Tags

Asked:

on 7 Oct 2020

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!