External Interfaces/API |
Creating an Array of Serial Port Objects
In MATLAB, you can create an array from existing variables by concatenating those variables together. The same is true for serial port objects. For example, suppose you create the serial port objects s1
and s2
You can now create a serial port object array consisting of s1
and s2
using the usual MATLAB syntax. To create the row array x
x = [s1 s2] Instrument Object Array Index: Type: Status: Name: 1 serial closed Serial-COM1 2 serial closed Serial-COM2
Note that you cannot create a matrix of serial port objects. For example, you cannot create the matrix
z = [s1 s2;s1 s2]; ??? Error using ==> serial/vertcat Only a row or column vector of instrument objects can be created.
Depending on your application, you might want to pass an array of serial port objects to a function. For example, to configure the baud rate and parity for s1
and s2
using one call to set
Refer to the serial port function reference to see which functions accept a serial port object array as an input.
The Serial Port Object Display | Connecting to the Device |