getSlope function issues for MATLAB code

5 Ansichten (letzte 30 Tage)
Doug Leaffer
Doug Leaffer am 9 Jan. 2025
Kommentiert: Walter Roberson am 9 Jan. 2025
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 Kommentar
Walter Roberson
Walter Roberson am 9 Jan. 2025
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.)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 9 Jan. 2025
Bearbeitet: KSSV am 9 Jan. 2025
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

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Support Package for Arduino Hardware finden Sie in Help Center und File Exchange

Produkte


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by