Undefined function 'writePosition' for input arguments of type 'double'

Hi, I have followed the guide from this page (https://www.mathworks.com/help/supportpkg/arduinoio/ug/control-servo-motors.html) on how to set up the servo motor via Arduino on Matlab.
However, I keep getting the following the error message: Undefined function 'writePosition' for input arguments of type 'double'
This page (https://www.mathworks.com/help//supportpkg/arduinoio/ref/writeposition.html) states that the writePosition function can take in any numeric value from 0 to 1, but yet the error shows up.
Why is this happening?
My code is as shown below:
Screenshot 2019-01-18 at 1.58.11 PM.png
Thank you.

7 commentaires

Do you have arduino hardware support package installed?
Hi,
Yes, I have the package installed and set up.
madhan ravi
madhan ravi le 18 Jan 2019
Modifié(e) : madhan ravi le 18 Jan 2019
which version are you using 2018a?
It's version 18.1.1
It's version 9.4.0813654. (64 bit)
I mean which release are you using 2018 a ?
Oh yes, I am using the R2018a.

Connectez-vous pour commenter.

Réponses (2)

change
function interval(x)
to
function interval

14 commentaires

I have done so, but the error still persists.
Type the below in command window:
which writePosition -all % what shows up?
Sorry, but i could not understand that.
What do you mean?
This showed up:
/Users/strider/Documents/MATLAB/SupportPackages/R2018a/toolbox/matlab/hardware/supportpackages/arduinoio/+arduinoio/ServoMotorBase.m % arduinoio.Servo method
madhan ravi
madhan ravi le 18 Jan 2019
Modifié(e) : madhan ravi le 18 Jan 2019
what's the value of s?
My value of s is:
Servo with properties:
Pins: D6
MinPulseDuration: 6.15e-04 (s)
MaxPulseDuration: 2.39e-03 (s)
However, if I were to run this code directly in the command window, it works. But it does not run properly as a function.
Screenshot 2019-01-18 at 3.16.20 PM.png
uncomment the two lines before global a , see that's why global is not recommended making it harder to debug!!!
But doing so will give me the following issues, while the writePosition issue still remains.
Screenshot 2019-01-18 at 3.27.49 PM.png
remove global a and global s
The error "Undefined function or variable 's'." will occur.
madhan ravi
madhan ravi le 18 Jan 2019
Modifié(e) : madhan ravi le 18 Jan 2019
how are you calling it ? by pressing the green triangle button ?can you upload the code?
Hi, thanks for the help so far.
I have reinstalled the package and the code is working again. Seems like some of the files got corrupted.
oh good , glad that you found , anytime :)

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Support Package for Arduino Hardware dans Centre d'aide et File Exchange

Produits

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by