| Data Acquisition Toolbox | ![]() |
Determine whether device objects, channels, or lines are valid
Syntax
Arguments
obj |
A device object or array of device objects. |
obj.Channel(index) |
One or more channels contained by obj. |
obj.Line(index) |
One or more lines contained by obj. |
out |
A logical array. |
Description
returns a logical 1 to out = isvalid(obj)
out if obj is a valid device object. Otherwise, a logical 0 is returned.
returns a logical 1 to out = isvalid(obj.Channel(index))
out if the channels specified by obj.Channel(index) are valid. Otherwise, a logical 0 is returned.
returns a logical 1 to out = isvalid(obj.Line(index))
out if the lines specified by obj.Line(index) are valid. Otherwise, a logical 0 is returned.
Remarks
Invalid device objects, channels, and lines are no longer associated with any hardware and should be cleared from the workspace with the clear function.
Typically, you use isvalid directly only when you are creating your own M-files.
Example
Create the analog input object ai for a National Instruments board and add eight channels to it.
To verify the device object is valid:
To verify the channels are valid:
If you delete a channel, then isvalid returns a logical 0 in the appropriate location:
Typically, you use isvalid directly only when you are creating your own M-files. Suppose you create the function myfunc for use with the Data Acquisition Toolbox. If myfunc is passed the previously defined device object ai as an input argument,
the first thing you should do in the function is check if ai is a valid device object.
function myfunc(obj) % Determine if an invalid handle was passed. if ~isvalid(obj) error('Invalid data acquisition object passed.'); end
You can examine the Data Acquisition Toolbox M-files for examples that use isvalid.
Functions
clear, delete, ischannel, isdioline
| isdioline | length | ![]() |