LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

matlab code not working in matlab script

Hi,


I am trying to run a piece of software written in matlab, through a matlab script node. It consists of a class interface to C++ code which creates a mex file. This then allows a number of modules to be run, to control both a projector and a webcam. Some of these modules work when I run them, but the key one I want will not work, which takes an image for the webcam.

 

The key point is that all of this works when I run it directly through matlab. However when I run it through matlab script in Labview, then the matlab command line crashes. I have tried to track this error down, but all I get is that there is something wrong with my mex file.

 

My understanding is that when you run a matlab script it calls matlab directly. I have 64bit matlab 2015, but I am running 32bit Labview, although i dont think this should cause the problem.

 

Does anyone have any ideas why something may work in matlab as normal but then not in matlab script via labview? Could it be a memory allocation issue, as the C++ code allocates a set amount of memory for the image to be taken.

 

Thanks,
Dan

0 Kudos
Message 1 of 3
(2,979 Views)

Hi Dan,

 

Have you tried using the 32-bit version of The MathWorks MATLAB® software instead?

 

I've noted from a post on the forums here that a user was doing something similar. His set up worked fine when using the 32-bit version of the MATLAB® software, but with the 64-bit version, the command window does not even launch.

 

Could you try using the 32-bit version instead and see if you get a similar behaviour?

 

MATLAB® is a registered trademark of The MathWorks, Inc. Other product and company names listed are trademarks and trade names of their respective companies.

 

Regards,

 

Mitch

0 Kudos
Message 2 of 3
(2,918 Views)

Hi Mitch,


Thanks for the feedback. I have now got it working, but I have installed 64bit Labview on a trial. I will probably have to update to a newer version anyway (with supervisors permission!) and now it works with 64bit Matlab.

 

Problem is all the mex files in my matlab program are compiled in 64bit and dont run in 32 bit Matlab so I would have to recompile them from source. I am still not 100% sure why this error occurs as the class works fine for some methods. It is only when I run the getImage method which actually takes a snap with the webcam that it fails, so I think there must be a memory mismatch between 64bit matlab and 32bit labview. The problem is I dont really understand how labview is dealing with memory from Matlab.

 

Anyway it works now for me with both 64 bit so that will do 🙂

Thanks for your help,

Dan

0 Kudos
Message 3 of 3
(2,910 Views)