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'.

 Réponse acceptée

Michael
Michael le 21 Nov 2025

0 votes

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!

Plus de réponses (0)

Produits

Version

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by