Effacer les filtres
Effacer les filtres

Calling Visual Studios from MATLAB

12 vues (au cours des 30 derniers jours)
Luca Fenech
Luca Fenech le 12 Mar 2021
Commenté : Luca Fenech le 16 Mar 2021
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.

Réponse acceptée

Image Analyst
Image Analyst le 12 Mar 2021
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 commentaires
Image Analyst
Image Analyst le 15 Mar 2021
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 le 16 Mar 2021
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Historical Contests dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by