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

Walter Roberson
Walter Roberson 2021년 6월 21일
Perhaps use gradient() ?
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일

0 개 추천

rpmArray = (radiansArray/(2*pi));
minutesArray = timeArray/60;
slopeArray = gradient(rpmArray)./gradient(minuteArray);

댓글 수: 1

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개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

질문:

2021년 6월 21일

댓글:

2021년 6월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by