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 个评论

Do you have arduino hardware support package installed?
Hi,
Yes, I have the package installed and set up.
which version are you using 2018a?
I mean which release are you using 2018 a ?

请先登录,再进行评论。

回答(2 个)

change
function interval(x)
to
function interval

14 个评论

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
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 :)

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

产品

版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by