# Defining velocity over particular time frame

1 view (last 30 days)
Max on 10 Jun 2019
Commented: Max on 10 Jun 2019
Hi all,
I was wondering whether I could reach out for some guidance. I am very new to matlab and I am trying to learn from scratch. I am trying to get to the point where I can define a start time and a stop time, and also a start velocity and an end velocity. The rate of acceleration is linear.
So for example I would like to accelerate my machine from 0rps to 100rps in 30 seconds, but retain the ability to change the time frame and the speed.
Excuse my basic attempt, but what I have so far is:
dt = 1; % delta time step (s)
tstart = 0; %initial time (s)
tstop = 30; %time final (s)
t = tstart:dt:tstop;
for i = 0:length(t)
RPS1 = 0; %initial rev/s
RPS2 = 100; %final rev/s
omega = RPS1:dt:RPS2;%instantaneous velocity
end
plot(t,omega)
Is this code representative of what I am trying to achieve? I think it is but would really appreciate clarification.
Would ideally like to plot this but the vector lengths are different.
Any guidance would be greatfully recieved.
Regards.

James Tursa on 10 Jun 2019
You don't need a loop for the velocity. Assuming I understand that you want the velocity to be linear, you just need a vector the same size as your time vector that increments in a linear fashion. E.g.,
RSP1 = whatever;
RSP2 = whatever;
omega = linspace(RSP1,RSP2,numel(t));

#### 1 Comment

Max on 10 Jun 2019
Thanks so much for your help! Really appreciate it!