The Instrument Control Toolbox™ software provides MATLAB® commands you can use in the Command Window or in files to create a device object that uses a driver, set and get properties of the object, and execute functions.
This example illustrates how to use the generic driver you created in Writing a Generic Driver.
If your driver is not in the
in the MATLAB Command Window, make sure that the directory containing
your driver is on the MATLAB software path.
If you do not see the directory in the path listing, and the
driver is not in the
add the directory to the path with the command
directory is the
pathname to the directory containing your driver.
Create a device object using your driver.
For the driver used in this example, the
does not require an argument for a resource when using a generic driver.
What the object connects to and how it makes that connection are defined
in the Create code of your driver.
ie_obj = icdevice('ie_drv');
Connect the object.
When the device object is connected, an empty IE window appears on your screen. Now you can communicate directly with the IE browser from the MATLAB Command window.
The driver you created allows you to specify where the browser
window appears on your screen and how large it is. You read and write
the properties of your device object with the
View all of the properties of your device object.
get(ie_obj) ConfirmationFcn = DriverName = ie_drv.mdd DriverType = MATLAB generic InstrumentModel = Interface = [1x1 COM.internetexplorer_application] LogicalName = Name = Browser-ie_drv ObjectVisibility = on RsrcName = Status = open Tag = Timeout = 10 Type = Browser UserData =  BROWSER specific properties: Top = 47 Vsize = 593
Most of the properties listed belong
to all device objects. For this example, the properties of interest
are those listed as
BROWSER specific properties,
Top property defines the IE browser window
position in pixels from the top of the screen.
the vertical size of the window in pixels.
Shift the IE browser window to the top of the screen.
ie_obj.Top = 0;
With the mouse, grab and drag the IE browser window down away from the top of the screen.
Find the window's new position by examining
ie_obj.Top ans = 120
Adjust the size of the window by setting the
ie_obj.Vsize = 200);
Make the window larger by increasing the property value.
ie_obj.Vsize = 600);
By using the
goTo function of your generic
driver, you can control the Web page displayed in the IE browser window.
View all of the functions (methods) of your device object.
methods(ie_obj) Methods for class icdevice: Contents disp icdevice instrnotify methods size class display igetfield instrument ne subsasgn close end inspect invoke obj2mfile subsref connect eq instrcallback isa open vertcat ctranspose fieldnames instrfind isequal openvar delete get instrfindall isetfield propinfo devicereset geterror instrhelp isvalid selftest disconnect horzcat instrhwinfo length set Driver specific methods for class icdevice: goTo
Most of the methods listed apply to all device objects. For
this example, the method of interest is the one listed under
specific methods, that is,
to specify the page for the IE browser to display.
invoke(ie_obj, 'goTo', 'www.mathworks.com');
If you have access to the Internet, the IE window should display the MathWorks Web site.
When you are finished with your example, clean up the MATLAB workspace by removing the object.
disconnect(ie_obj); delete(ie_obj); clear ie_obj;
Close the IE browser window you created in this example.