I'm trying to use Arduino in Matlab. cause I used Arduino in some function I had to define Arduino as a global variable.
clc,clear,close all;
global a
a = arduino();
.
some functions
.
clear a
at the end of my code I clear the variable but as I run the code again this error appear:
Failed to open serial port (user COM) to communicate with board Uno. ...
Make sure there is no other MATLAB arduino object for this board.
I guess the global function can't be clear by clear command so I tried clear all instead clear in the last line. It works perfect as I run it again and again but as you know this is Matlab tips for clear all command
Using clear all causes MATLAB® to recompile previously cached code,
and can decrease performance.
I've tried delete(a) so the result was:
Error using arduino/delete
Cannot access method 'delete' in class 'arduino'.
any help would be appreciated.
a = arduino();?writePWMDutyCycle(a,E1, 0);matlab. one way is useaas an input argument for all of function. but i'm looking for another solution.