Defining velocity over particular time frame

조회 수: 6 (최근 30일)
Max
Max 2019년 6월 10일
댓글: Max 2019년 6월 10일
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
James Tursa 2019년 6월 10일
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
Max
Max 2019년 6월 10일
Thanks so much for your help! Really appreciate it!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by