MEX files aned SerialPort C++ class
1 view (last 30 days)
Show older comments
Hello,
I am using Visual Studio 2010 Express to work with the serial port. I have a C++ program running and it's sending and reading data from the serial port. I'm using C++ because of the SerialPort class which was quite simple.
My programm is running and writing data in a csv file which is used in MATLAB after to plot data.
I would like to know if it is possible to transform this progam into a MEX file code so it would write data directly in MATLAB instead of a file. I would have one operation less so it would be simpler.
Thanks, Helene
1 Comment
James Tursa
on 24 Apr 2013
Do you know how big the data set is going to be before you start gathering data?
Answers (2)
Jan
on 24 Apr 2013
You can call C++ functions through the MEX interface. You find a lot of manuals and examples here in this forum, in the examples shipped with Matlab and when you ask your favorite internet search engine.
1 Comment
Tharindu Weerakoon
on 28 Jan 2015
Hello Jan,
I'm using Microsoft VS 2012 and MATLAB R2012a on Windows 7 OS. I have to create a serial port C++ mex file for MATLAB to read and write the data for my sensor model (Hokuyo URG-04LX). Any how I tried to create a mex file but couldnot. Can you please give me some guide and example serial port mex file compatible to my OS.
I hope that C++ console project only will work to make mex file/ or dll. Am I right? Is it possible to make mex file with C++ (C or C#)Windows form application?
Can you give me some solution?
Thanks.
Helene
on 24 Apr 2013
1 Comment
Jan
on 24 Apr 2013
Please post comments in the comment section.
The degree of usefulness of the examples depends on what you are looking for. The job of the mex function is to convert the Matlab input to the kind of input you need for the C++ part of the program, and finally convert the output of your function back to Matlab arrays. The methods you need for this can be found in the examples.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!