This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Number of instances of a resource


count = getResourceCount(arduinoObj, resourceName)



count = getResourceCount(arduinoObj, resourceName) returns the number of resource instances with the name resourceName. Use this function to keep track of the number of resource objects that exist in the current workspace.


collapse all

Create a servo object, and get a count of resources.

Create a servo object.

a  = arduino();
s = servo (a, 'D2');

Check the current resource count.

arduinoObj = obj.Parent;
count = getResourceCount(a,'servo')
count = 

Input Arguments

collapse all

Arduino object, specified as an object that is an internal variable called from within classes that derive from matlabshared.addon.LibraryBase.

Name of resource to count, specified as a character vector.

Output Arguments

collapse all

Number of instances for a given resource, returned as a double.

Introduced in R2015b