Calling Visual Studios from MATLAB

15 次查看(过去 30 天)
I have a program that is written in visual studios. Its extention is '.snl'. So to compile this program I go to visual studios, and press 'run'. Is it possible that instead I run this program from Visual Studios, I go to MATLAB, and MATLAB will call visual studios and run the program.
I have been doing some research to try and use the 'Mex File Functions', but till know I had no luck.
Any help would be appreciated. Thanks.

采纳的回答

Image Analyst
Image Analyst 2021-3-12
In Visual Studio, clicking Run does not compile the solution. It runs the program. To compile the code into a standalone executable you need to go to the Build menu and then select Rebuild Solution. Make sure the configuration says "Release" and that you have set up the Build/Configuration Manager to build the output executable in Release mode.
Once Visual Studio has built the executable, you can run the executable from MATLAB with the system() function. I believe it's the best way. Trying to have MATLAB launch Visual Studio, load your solution, and then run it from within Visual Studio will be A LOT harder. It's probably possible if you use ActiveX since most or almost most Microsoft programs can be controlled via ActiveX function calls. But it's a lot harder. Your best bet is to make the executable and simply run it with the system() function.
  4 个评论
Image Analyst
Image Analyst 2021-3-15
Your dosCommand should have whatever command line arguments you want to send into the program.
programName = 'C:\Users\fenec\Documents\IC Imaging Control 3.5\classlib\x64\debug\HighSpeedCapture.exe';
commandLineArguments = 'whatever you want';
% Now combine them into one character array.
systemCommand = sprintf('%s %s', programName, commandLineArguments);
system(systemCommand);
Luca Fenech
Luca Fenech 2021-3-16
Thanks for the info.
I managed since than the program opened and worked
I just wrote this code:
status = system(' c:\Users\fenec\Documents\IC Imaging Control 3.5\classlib\x64\debug\HighSpeedCapture.exe ')
Thanks a lot for your help.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by