How to call a program in C from Matlab

I used to call a program in C to change parameters in a camera, since the product came with examples in this language.But for sake of automation it would be more efficient do it all from a main program in Matlab.-The key is how to pass the values to the functions and make that the program in c read the values from the functions in my "m" file.Command System works for me, but if there is another way to dothis...I appreciate a clue

Answers (1)

You need to write a MEX-function that can perform the data marshaling. See MEX-files Guide.

4 Comments

Thanks! Kaustubha, but i've already check the mex option -and its very overwhelming.Another thing is the camera i am controlling has its parametres involved in c code with tons of stuff I 'd prefer not modify.
Wrapping your camera control code with MEX should not be a problem if you are familiar with C. You simply create a C source file with the MEX entry function, #include your camera-control stuff in that file, and translate the supplied MatLab parameters into their C equivalent. There is a lot of MEX example code on the web that gives you the basic MatLab API calls. From there, it's just ordinary C.
@Warren: The Mex-gateway is the best solution. If this interface is "overwhelming" for you, this forum is a good location to post your trials and ask specific questions about the mex<> and mx<> commands.
I agree with Geoff and Jan!

Sign in to comment.

Categories

Asked:

on 26 Mar 2012

Community Treasure Hunt

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

Start Hunting!