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 Comments

Do you have arduino hardware support package installed?
Hi,
Yes, I have the package installed and set up.
which version are you using 2018a?
It's version 9.4.0813654. (64 bit)
I mean which release are you using 2018 a ?

Sign in to comment.

Answers (2)

change
function interval(x)
to
function interval

14 Comments

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
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
The error "Undefined function or variable 's'." will occur.
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 :)

Sign in to comment.

Categories

Products

Release

R2018a

Asked:

on 18 Jan 2019

Answered:

on 11 Sep 2021

Community Treasure Hunt

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

Start Hunting!