Defining velocity over particular time frame

2 vues (au cours des 30 derniers jours)
Max
Max le 10 Juin 2019
Commenté : Max le 10 Juin 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.

Réponse acceptée

James Tursa
James Tursa le 10 Juin 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 commentaire
Max
Max le 10 Juin 2019
Thanks so much for your help! Really appreciate it!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by