MATLAB Answers

0

Matlab recognizes arduino but not other code.

Asked by Andrew Miller on 17 Oct 2014
Latest activity Commented on by Walter Roberson
on 11 Nov 2016
I'm pretty new to using matlab/arduino together so this is probably a simple problem. I installed the arduino add-on from mathworks and have gotten matlab to recognize my arduino uno using:
a = arduino('COM3');
but none of the arduino commands work that I have tried:
a.pinMode(13,'output');
pinMode(a,13,'output');
a.digitalWrite(13,1);
digitalWrite(a,13,1);
a.analogRead(0)
analogRead(a,0)
and all of them bring up the same error message:
' _No appropriate method, property, or field pinMode for class arduino._'
I'm not sure why they don't work.

  0 Comments

Sign in to comment.

Tags

3 Answers

Answer by Andrew Miller on 1 Nov 2014
 Accepted Answer

Thanks a lot for your help. I was still having the same problem after installing it as an administrator so I looked at the MATLAB Arduino help and it appears that they have changed the coding syntax. For example: to specify output pins then instead of a.pinMode(22,'output') then it is a.configureDigitalPin(22,'output') or turning on the power instead of a.digitalWrite(22,1) then it is a.writeDigitalPin(22,1). I'm not sure on what version of MTALB the change took place but this fixed the problem.

  2 Comments

This answer solved my problem as well. Thank you.
jahanzeb hasmni comments to Andrew Miller:
very authentic and right on the target.

Sign in to comment.


Answer by Geoff Hayes
on 18 Oct 2014

Andrew - a similar problem was discussed matlab and arduino where the same error No appropriate method, property, or field pinMode for class arduino. The solution was to install the Arduino support package after having started MATLAB in administrator mode.

  4 Comments

Show 1 older comment
I suppose it depends on how Andrew switches to being an Administrator on his workstation. If he can start MATLAB by right-clicking on the icon and selecting Run as administrator, then that should just give his user account elevated privileges and the install will occur under his account. This is based on installing arduino support package as administrator.
Andrew's comment moved here
Ok. So I read through the post that Hayes suggested and it talks about about making other users have the same preferences as the administrator. The problem is that I only have one account on a windows 8 laptop and it is set up as the administrator. I ran matlab R2014a (student version) as an administrator, right clicked on the package. It didn't have an option for install as administrator. So I just double clicked on it and it then opened up another matlab window and insalled the package. Since it opened up another matlab window then I'm not sure if it is installing as an administrator. Do I also need to install the package as an administrator and if so how would I do that? Also it looks like the packages are located in the following folder
C:/MATLAB/SupportPackages/R2014a if that helps.
Obviously you can ignore the part about the other user accounts since there is just you using that computer.
Rather than running the installation package through your browser (which does seem to open a new instance of MATLAB), just save it to file (when I tried it now, the saved file is arduinoio.mlpkginstall). Then launch your instance of MATLAB as an administrator. Change directory to the folder where the install package has been downloaded (or move that file to your default MATLAB directory), then double-click on the file. It will launch the Support Package Installer without launching another instance of MATLAB.

Sign in to comment.


Answer by yati j
on 6 Oct 2016

Hi! i had downloaded the package IO Library but after i wanna add to the matlab, matlab see nothing in my folder..how can i add the io library..thank You

  7 Comments

For MATLAB use of arduino up to R2013b you need the legacy package at http://www.mathworks.com/matlabcentral/fileexchange/32374-legacy-matlab-and-simulink-support-for-arduino Download the .zip into a convenient directory and unzip it. Then in MATLAB cd to the directory and run install_arduino
For Simulink up to R2013a you need the legacy support package, which installs a similar way.
Download the .zip into a directory, and unzip it, and in MATLAB cd into the directory and run install_arduino

Sign in to comment.