Defining velocity over particular time frame

7 visualizaciones (últimos 30 días)
Max
Max el 10 de Jun. de 2019
Comentada: Max el 10 de Jun. de 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.

Respuesta aceptada

James Tursa
James Tursa el 10 de Jun. de 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 comentario
Max
Max el 10 de Jun. de 2019
Thanks so much for your help! Really appreciate it!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by