Converting a Matlab Script from MexConnect to COM?

« Go Back


QuestionHow do I convert a MATLAB script from MexConnect to COM?
If you have written your MATLAB script using the MexConnect interface and want to switch over to COM, it is very straightforward if you just use Connect commands. This will free you from being locked to the constraints of the MexConnect interface, and it will give you more configuration flexibility and coding options.

Sample MexConnect .m file 

conid = stkOpen;
stkExec(conid, 'New / Scenario MATLABExample');

Converted COM .m file

uiApplication = actxserver('STK12.application');    %Change STK11 to start a different STK version
uiApplication.Visible = 1;
root = uiApplication.Personality2;
root.ExecuteCommand('New / Scenario MATLABExample');

After you switch the first couple of lines to use the COM interface, then you can do a Find and Replace to update all the stkExec(conid,  commands to be the new format of root.ExecuteCommand( commands.

You can learn more about all the ways to integrate STK and MATLAB at STK Help > Integrating with STK > MATLAB Interface or from the How do I connect STK and Matlab? FAQ article.
TitleConverting a Matlab Script from MexConnect to COM?
URL NameHow-do-I-convert-a-Matlab-script-from-MexConnect-to-COM

Related Files