run mex without argument
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I am creating a c++ code for A* algorithm. I want to run it in the matlab because later i want to perform the simulation. I have created the mexfunction. I want to know how i can call the main(replaced by the mexfunction) from matlab command without passing the argument because i don't think(for the time being because so far this is all i can think) i need to pass any parameter to call the mexfunction. Some of the data i already define as constant inside the c++ code?
I am just moving to matlab and any misconceptions please clarify. Thank you in advance.
0 Kommentare
Akzeptierte Antwort
James Tursa
am 17 Jun. 2013
Bearbeitet: James Tursa
am 17 Jun. 2013
If you are not passing in any arguments or passing out any results, it is pretty simple. Just replace the "main" line with the "mexFunction" line as you have apparently already done. Suppose the filename is myfunction.cpp, then take these steps:
1) Put myfunction.cpp in a directory that is on the MATLAB path.
2) Make that directory your current directory.
3) Issue the following command at the command line prompt:
> mex myfunction.cpp
That will create the mex function for you. Now you can invoke it just like any other function. During compilation if you get a question about searching for compilers, answer Yes, press Enter, then select the number of the C++ compiler that you have installed and will be using. Note that MATLAB does not come with a C++ compiler, you have to get that and install it yourself separately.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!