Matlab command language supports DDE and
therefore can be used with the Wedge in the DDE Server mode.
Example #1
Launching the WinWedge from MATLAB
Steps for setting up WinWedge:
1. Select "DDE Server" from WinWedge
"Mode" menu. When the dialog box appears asking for a DDE Command Destination
Application, enter: "MATLAB" as the Application Name and then enter:
"Engine" as the DDE topic.
2. Set up the rest of the WinWedge parameters and then
save and quit.
Steps for setting up MATLAB:
1. Create or edit a .m file and enter the following code in
the file:
cd ('c:\Program Files\WinWedge');
dos ('winwedge.exe myconfig.SW3 &');
cd ('d:\matlab\bin');
This code launches the wedge with the specified config file
and then returns to the original working directory in MATLAB. Save this .m file as
invoke.m and launch from the MATLAB >> prompt.
Example #2
Requesting data from the WinWedge
Create or edit a .m file and enter the following code in
the file:
while chan == 0
chan = ddeinit('winwedge', 'com1');
end
mydata = ddereq(chan, 'field(1)');
rc = ddeterm (chan);
disp(mydata);
This function establishes a DDE channel between the Wedge
and MATLAB. Then it retrieves the content of field(1) in the wedge and perform the
disp(mydata) operation that displays the data that was retrieved from the wedge in
MATLAB's command window. The disp(mydata) is just a small example of what can be done with
the data once it is brought into the MATLAB. The disp(mydata) could also be swapped for a
call to another .m file to run even more MATLAB code.
Example #3
Closing the WinWedge
Create a .m file called dismiss.m with the following code:
chan = ddeinit('winwedge', 'com1');
ddeexec(chan, '[APPEXIT]');
These two lines initiate a link with the wedge and then
close the WinWedge application. This code assumes the WinWedge is already
activated in the background.
|