Using Matlab within VC++

Hey guys,

I have been using Matlab for years and am relatively experienced using it. Recently at work, I've been tasked with taking a huge program, written in C on a linux machine, and getting it to work in windows with Visual. The problem is, I have to take the code apart and put it back together, which is not easy for someone who has only 1 semester of C/C++ in college 8 years ago and hated the class.

I can do everything I need to do, from scratch, in Matlab. My question is, I've seen references to Matlab COM builder on this site, but I am not quite sure how it works and how to implement it. For example, I have a single successful Visual C++ program that reads in a .dat file which contains header info and 3 video streams, and my program parses the single file into 3 separate video files. Now, I have no clue how to take these 3 .dat files and view them with Visual C++, but I wrote Matlab code to do it in about 3 minutes...

So, how easy is it for me to take the 2 matlab functions I wrote and incorporate them into VC++ to display data? I would love it if I could just call a Matlab function within VC++ and have those vids pop up, but I know it's probably not that easy.

Thanks in advance,
-Doug
[1271 byte] By [dougAAC] at [2007-11-19 19:44:10]
# 1 Re: Using Matlab within VC++
So, how easy is it for me to take the 2 matlab functions I wrote and incorporate them into VC++ to display data? I would love it if I could just call a Matlab function within VC++ and have those vids pop up, but I know it's probably not that easy.

Hi. First of all I think you must read this (http://www.codeproject.com/macro/using_matlab_add_in.asp) article. Now if you want the opposite (to use c code in matlab) visit this (http://prism.mem.drexel.edu/Shah/public_html/mex2c.html) link.

I have done this (I also write mostly Matlab code) in the past a couple of times. So let me give you a couple of advices:

If the reason you want to convert Matlab code to VC is speed, then I think you should reconsider using the Matlab plugin for visual studio. They say it is faster than Matlab, but in fact the difference is very small (at least with the Matlab 6.5 plugins). So if you really want a fast project, then I think you should use C/C++ code from the beginning.
Is this for commercial purposes? Because if yes, then you can't do this, since when using matlab calls from VC there are tons of Matlab dlls that have to be loaded.
Finally, I have experienced problems when using several Matlab editions. For example, the dlls used for this purpose in matlab 6.5 are completelly different from other matlab editions.


On the other hand, if you only need it for research purposes and you are not interested in speed, then go ahead...

Hope I gave u a general idea.

Regards,
Theodore
yiannakop at 2007-11-9 0:57:44 >
# 2 Re: Using Matlab within VC++
Ah, and sth else:you told you want to deal with video processing etc. For that purpose you could also use intel's opencv. Link here (www.intel.com/research/mrl/research/opencv/). I think it is quite good for these purposes.

:wave:
yiannakop at 2007-11-9 0:58:38 >
# 3 Re: Using Matlab within VC++
Thanks a lot for the help! It is sort of for commercial purposes, but it's a one-time installation test, not realtime but just for post processing purposes. Speed is always a concern but if I can get it working at a base level and acceptable speed, it will be fine.
dougAAC at 2007-11-9 0:59:45 >
# 4 Re: Using Matlab within VC++
Hi,

I think you folks could help me with some information.
Right now I am into image processing and I need to convert the previosuly developed codes in Matlab to C/C++ using OpenCV tool.

Can you provide me more information on this and how to proceed, any relevant links/documentation would help me out.

Thanks!!
flavourofbru at 2007-11-9 1:00:40 >
# 5 Re: Using Matlab within VC++
Well, OpenCV is sth totally different than matlab. In any case, there is not any standard way to convert Matlab code to C code (which uses OpenCV). You can ofcourse use the matlab compiler, to produce libradies and dlls, but again I suppose that this is not the point, since OpenCV has its own libraries for images/video manipulation. Anyway, if you have any specific question on OpenCV you can ask and maybe someone would answer (I've used some OpenCV in the past for simple video processing, but it's been a couple of years).
Regards.
yiannakop at 2007-11-9 1:01:44 >