Defining velocity over particular time frame

7 ビュー (過去 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 Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by