Arduino Mega 2560 LIS3DH Undefined Function

Hey there! I am getting this weird error when trying to use the LIS3DH library.
My code:
% accelerometer
clc
clear
close all
a=arduino("/dev/cu.usbmodem1101","Mega2560");
accelerometer = lis3dh(a)
accelReadings = readAcceleration(accelerometer)
The error:
Error using accelTest (line 8)
Invalid default value for property 'IsDataReady' in class 'lis3dh':
Undefined function 'boolean' for input arguments of type 'double'.

 채택된 답변

Michael
Michael 2025년 11월 21일

0 개 추천

Copilot instructed me as follows, and this solved the problem:
which lis3dh -all
This would find the lis3dh class. It then instructed me to open the file and replace all instanced of boolean() with logical(1) or logical(0) or true or false. I replaced all instances of boolean(1) and boolean(0) with true and false respectively, and then in cases where the boolean function had another parameter, I just replaced it with the logical() function as copilot instructed.
I then cleared the classes with
clear classes
as copilot instructed, and restarted matlab as copilot instructed. This would create the variables with the new lis3dh class. I then ran the code, and it worked!

추가 답변 (0개)

제품

릴리스

R2025b

태그

질문:

2025년 11월 21일

답변:

2025년 11월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by