フィルターのクリア

Radians to RPM with diff(..) function

6 ビュー (過去 30 日間)
Kenneth Metzsch
Kenneth Metzsch 2021 年 6 月 21 日
コメント済み: Kenneth Metzsch 2021 年 6 月 21 日
Hi...
I need to finde the RPM from a vector of radians and a vector of seconds (time).
I can do this manually by doing this:
rpmArray = (radiansArray/(2*pi));
minutesArray = timeArray/60;
slopeArray = [];
for counter = 1:length(minutesArray)
if counter < length(minutesArray)
x1 = minutesArray(counter);
x2 = minutesArray(counter + 1);
y1 = rpmArray(counter);
y2 = rpmArray(counter + 1);
slopeArray(counter) = (y2-y1)/(x2-x1);
end
end
slopeArray(end + 1) = slopeArray(end); % Fill in the missing entry
I can not figure out how to do this the "smart way" by using Matlabs diff().
Can anyone help me?
  3 件のコメント
Kenneth Metzsch
Kenneth Metzsch 2021 年 6 月 21 日
I think it gives me the same problem as diff().
It assumes spacing is 1.
Can you give me an example of how to overcome this?
Stephen23
Stephen23 2021 年 6 月 21 日
"It assumes spacing is 1."
Did you look at the h/hx/hy inputs?

サインインしてコメントする。

採用された回答

Chunru
Chunru 2021 年 6 月 21 日
rpmArray = (radiansArray/(2*pi));
minutesArray = timeArray/60;
slopeArray = gradient(rpmArray)./gradient(minuteArray);
  1 件のコメント
Kenneth Metzsch
Kenneth Metzsch 2021 年 6 月 21 日
Thank you...it works
Actually it wil also work with diff() like this
rpmArray = (radiansArray/(2*pi));
minutesArray = timeArray/60;
slopeArray = diff(rpmArray)./diff(minutesArray);
slopeArray(end + 1) = slopeArray(end);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by