getSlope function issues for MATLAB code

조회 수: 5 (최근 30일)
Doug Leaffer
Doug Leaffer 2025년 1월 9일
댓글: Walter Roberson 2025년 1월 9일
I am trying to run this program in MATLAB R2024a but getting errors:
I might just be reading the code wrong but it looks like this script used a function 'getSlope' on line 93 of the 'Run_Motion_Detector' function. When I try to run this code it displays an error saying it (getSlope) is an undefined function or variable. Am I missing this function in an update or has it been replaced by a recent update? Is there an equivalent function in MATLAB I can code as a substitute ? The code's authors states:
  • Slope Method - calculates a best-fit linear slope for a window of data. Requires both the voltage readings and their corresponding timestamps.
  댓글 수: 1
Walter Roberson
Walter Roberson 2025년 1월 9일
You have not overlooked anything. The function getSlope is used by that File Exchange contribution, but the function getSlope is defined by only one File Exchange contribution (defined in an incompatible manner.)

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

채택된 답변

KSSV
KSSV 2025년 1월 9일
편집: KSSV 2025년 1월 9일
You can implement this function in few lines from the Method you have mentioned.
Let x be your voltage readings and y be their corresponding timestamps..
p = polyfit(x,y,1) ;
m = p(1) ; % m is the slope

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by