Matlab DLL

I was wondering if somebody help me how I can use Matlab dll (creating in Matlab 7) in LabVIEW. Many thanks

The Matlab exports an ActiveX element. So you have to register first this DLL and then call it.
At the test.vi which is attached you can find the way to call it.
1) Select the desired matlab class (At the diagram right click the Automation constant and choose the select option)
2) Call the Method / function
3) Close the Class
The vi is broken beacuse you have to select the desired method.
There are 10 kind of persons. Those who understand binaries and the others.
Attachments:
test.vi ‏11 KB

Similar Messages

  • I would like to convert a matlab file into a .dll and use it in LabVIEW. However, when I run the .dll in LabVIEW I get an error stating "... Procedure not found". What could this be? Can anyone help me...

    I wish to convert my Matlab files into .dll's so that I can use them in LabVIEW. I am using 'mcc' and 'mbuild' of Matlab to convert my .m files into .c and .dll.
    When I try to run the .dll's in LabVIEW, I get an error message in a modal window stating some required .dll or procedure is not found.
    How should I resolve this issue. Should I add any other Matlab .dll's in course of making my .dll?
    Please help in solving this issue... Thankyou very much.

    KJV wrote in message news:<[email protected]>...
    > When I run the matlab generated dll, it is stating 'matllb.dll not
    > found'. Is it that I should set the path for matlab\bin to include
    > all the dll's before I compile? When I make dll from C, it works fine
    > in LabVIEW. The problem is from .m to .dll. The problem also arises
    > when I convert my .m to .exe. The same error of 'matllb.dll not
    > found' comes over. Should I change my matlab compiler options or
    > something else? Please help me?
    I have the same question,I don't know how to use the matlab DLL file in labview,
    I hope someone can descripe the procedure in detail.

  • How to use matlab compiled DLL in Labview ?

    I have LV 8.5, and am unable to use a matlab compiled DLL in my LV code. I have tried the 'import'  command, but it does not list any functions. However, it does not show any errors during its execution. The existing solutions/responses to this question do not work either. I would also like to know of a way to deal with mxArray datatype. What is its equivalent in C (or any other high-level language) ? How do I retrieve an array that is returned from the matlab dll ?

    I'm assuming you have either Matlab installed or at the very least the Matlab Runtime, otherwise the DLL won't work. The "import" command relies on having a header file. Do you have one? You also need to make sure the DLL has been compiled so that it's compatible with LabVIEW. The most likely problem is name mangling, which also occurs when you try to compile a DLL written in C++. See this post, which contains links to useful posts.
    The mxArray datatype is a special datatype which is actually a structure. It's complicated. Your best bet is to create a C DLL that acts as an intermediary between the Matlab DLL and LabVIEW. If you are able to, you can, instead, simply call the Matlab code directly using the Matlab script node.

  • How to generate and use Matlab(R2007) .dll's in Labview

    Is there a step-by-step example on how to generate and use Matlab(R2007)  .dll's in Labview.
    Our experimenal hardware is LabView-controlled and we want to pass
    images/2d intensity arrays to a more complex matlab program that will
    return an array of extracted data which we want to use in LabView again.
    Thank you
    Carsten

    I recommend having a wrapper created around the matlab dll that converts the datatypes for you. There is a lot of fooling around with pointers involved which is very difficult in LabVIEW. btw, this got much more complicated after Matlab 7. Essentially, you need to convert your inputs into mxArrays, and then add those mxArrays to an mxArray list that you pass by pointer into the matlab dll. You also need to create a mxArray list for the outputs from the dll which you will need to extract your data out of before converting it back into a LabVIEW supported datatype. It's a big hassle. We do this pretty often, but we have created a c library that handles all the conversions, so it is feasible for us. Unfortunately, I can't share the library, but hopefully this information will help you get where you want to be.
    Like I said, it would be easier if you can just get a c developer to write a wrapper for you to keep it simple in LabVIEW. Alternatively, you might try getting your m-code to work in Mathscript.
    Chris

  • Function calls to a dll compiled by matlab

    In matlab I created a dll. I now need to access the functions within this dll from my java application.
    How is this achieved?
    Thanks,
    Anuj.

    Could you provide example code to how a method in a dll,
    that wasn't compiled in java can be accessed. The method
    i am trying to call is called "test" and the dll is called test.dll.You cannot call a dll directly from java, as jsalonen suggested. Instead you have to create a JNI DLL and do all the native work you wand from there.
    In the native implementation of the test method you should call LoadLibrary to load the matlab dll and GetProcAddress to get the addresses of the functions that you want to call. As you can see, we have now switched from Java Programming to Windows development, so if you have trouble doing the above, then you should try to find a more appropriate forum to post your questions
    LoadLibrary function:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibrary.asp
    GetProcAddress function:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocaddress.asp
    DLLs in general
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dynamic_link_libraries.asp
    Hope these help.

  • Matlab vs. C DLL

    I have an algorithm written in Matlab that I need to integrate into a LabVIEW VI.  In our current version of the software, we use a DLL written in C that I compiled in Visual Studio through a long period of trial and error.  I need to make some significant updates to our code and would much prefer to keep it in the Matlab environment that I’m more comfortable with.  Unfortunately, using a MathScript node is not an option due to the complexity of the algorithm and our desired processing speeds.
    Initially I thought I would buy the Matlab Compiler and use it to create the DLL, which I’d then call in LabVIEW, problem solved.  However, after reading through several threads about Matlab DLLs on the discussion board, I am concerned about all of the issues that people seem to have had when trying to do this.  Can anyone offer some insight into whether these Matlab DLLs usually cause problems in LabVIEW VIs or if these are isolated incidents?  Do they always need to be called through a secondary C DLL?  Thanks in advance!

    It's been a little while since the last time I did this, but I think I can answer some of your questions. One, there's a good chance that the c-dll will run faster than the Matlab dll, unless you are using some functions that were heavily optimized for Matlab. You can use the compiler to create a dll and call it from LabVIEW, but you will have to create some sort of interface to convert the datatypes (outside of LabVIEW). You may have better luck if you use an older version of Matlab. 6.5 and prior would actually generate compiled code, and as long as you have the 90 or so dlls installed correctly, would run very quickly. These compiled dll's were also easier to call, but still require an interface to LabVIEW. Since Matlab 7 (R14), the compiled code will run exactly like it does in Matlab (i.e., with the same performance), and is easier to get compiled and running (just install the runtime). Previously, not everything would compile. Now, if it runs in Matlab, you can use the Matlab compiler to create a dll. We've created an internal c-library of functions that allow us to create and handle the pointers to the Matlab datatypes so we can work with Matlab generated code all in LabVIEW, but it is still a hassle. Unfortunately, I can't share this library.
    A better option, but not always feasible is to use Real Time Workshop to create c code from your Matlab code. This can be done quickly, and will generate an actual dll that has traditional datatypes. These can be called directly from LabVIEW. Unfortunately, RTW requires Simulink and Matlab, and all of that will set you back ~$15k if you don't already have it.
    Of course, there is always the Matlab script node, which works fine as long as you don't mind having Matlab installed on your test machine. This is the way we usually go for initial testing or quick demonstrations. It's much easier to modify the Matlab code this way during debugging. I'm not positive, but I think you can build an executable in LabVIEW and still call the Matlab script node, which can target a script explicitly somewhere in the file system. That way, you can tweak the "analysis" portion of the code on a built executable even without rebuilding in LabVIEW.
    Finally, the Mathscipt nodes. I wish they would work, but we rarely actually get anything to work in them. The problem is that everyone developing m files does so in Matlab, not Mathscript. Then when we try to take something they've built and get it running in Mathscript we are bled to death by a million little cuts. I don't think structures or cell arrays work, and it just seems like we always run up against a little annoying thing that keeps us from using them. We are even paying for the Mathscript RT licenses now (or soon anyway) just in case someday we get something to work. I'm not a Matlab guy myself, so I can't really explain the problems clearly, but it seems like the code always has to be re-done for Mathscript, and that is not something the Matlab guys are too enthusiastic about.
    sorry if I rambled a bit.
    Chris
    edit: wow, all my linefeeds disappeared.. FIXED

  • Programmable choose Matlab ActiveX DLL

    Hi,
    We are using Labview with Matlab ActiveX DLL. Everything work fine. But, every one we recompile the Matlab DLL, I need to re link the static reference to the new Matlab DLL. It's possible to get the link dynamic?
    So, if we recompile the dll (keeping the same input, output, functionName, version), I don't need to re link my reference, only : 
    1) regsvr32 -u test.dll,
    2) remplace the C:\Y_Code\test.dll with the new one
    3) regsvr32 test.dll
    I include the basic VI, the 3 different Matlab DLL (can be rename).
    Test_1_0_1.dll = Add m+n+1.1
    Test_1_0_2.dll = Add m+n+2.2
    Test_1_0_3.dll = Add m+n+3.3
    Off course, you will need the Matlab Runtime MCR7.10 (if need, I can send you the runtime, but 152Meg...)
    Thank
    Solved!
    Go to Solution.
    Attachments:
    DynamicReference.zip ‏706 KB

    smercurio_fc wrote:
    Your question is not specific to Matlab, as it applies to any ActiveX. It has also been asked before. What you are asking for is not possible in LabVIEW.  You would need to create some form of wrapper DLL that will actually interface to the ActiveX component.
    Thank
    How I can make a wrapper? I don't really understant what is a wrapper
    Thank

  • Can I call .m files from a LabVIEW executable without the full developmen​t version of matlab installed?

    I have an executable that I am trying to build (and distribute).  Right now, it has Matlab script nodes that call some matlab .m scripts that someone else wrote.  The target PC will not have the full development version of Matlab installed.  Would that work?  I have tried to compile the .m scripts into a DLL, but I can't import that to LabVIEW because of the special Matlab types (*mxArrays).  I have also tried to write a wrapper around that DLL, but with no success.  So now I'm wondering if I can either call the Matlab .m scripts directly from a Matlab Script node OR if I can call my Matlab DLL from within a script node.  OR any other idea someone might have...
    Thanks a lot!
    -Matt Bradley
    ************ kudos always appreciated, but only when deserved **************************

    Simon,
    I looked at MathScript and am considering using it, but one thing that is not clear to me is if I will be able to use my .m files like I can with Matlab.  I call the same Matlab script repeatedly and it keeps track of some information in global variables (for example, the number of consecutive detections).  Can I do that entirely within mathscript or would I have to reload all of the info each time -- if I had to do that, it would mean substantial changes to the .m files ... and that's not an option.
    -Matt
    -Matt Bradley
    ************ kudos always appreciated, but only when deserved **************************

  • Matlab script no longer works after upgrade of matlab

    First of all im using labview 7.1.1 to execute a vi which uses some labview scripts to do the bulk of the number crunching and  labviews excellent interface.
    The problem happened when i recently was forced to use Matlab 7.1 R14 SP3 because some of my other routines required this.  After i had upgraded matlab and tried to run the labview vi, all i keep getting is an error no. 1050 from the matlab script object.
    Now the most infuriating thing about this is that it is such a non descript error, i mean , what does it actually mean? and as such i dont even know where to start in solving this problem.
    Has anyone solved this problem or indeed had it themselves, im at the end of my tether with it now.
    Thanks for your help
    Neil

    This is a known problem between different version of Matlab and LabVIEW. Mathworks changed the Matlab interface with version 7, which broke a lot of LabVIEW code. Which version of Matlab were you using before? You can try searching these forums for "matlab error 1050 labview" and you'll see what I mean. Typically he problem is the version of the matlab.dll that's in the LabVIEW installation directory. You can try the stuff suggested in this article.

  • Using Matlab in Labwindows/CVI

    I have a matlab .m file that runs a function. In my Labwindows software, I want to be able to run this function. Is this possible? Thanks.

    Hi Kamkon,
    Have you had a chance to look into the example posted by Anna? I've come across discussion forums regarding how to use MATLAB dlls in LabWindows CVI. They are listed below. I hope this is of some help to you.
    http://forums.ni.com/t5/LabWindows-CVI/How-to-use-a-Matlab-DLL-in-CVI/m-p/548105?requireLogin=False
    http://forums.ni.com/t5/LabWindows-CVI/Linking-Matlab-generated-lib-files/m-p/283814?requireLogin=Fa...
    Creating a MATLAB dll is somewhat outside the scope of our suppot. However, I have found a third party link on this topic. Hopefully, it will point you in the right direction.
    http://www.mathworks.com/support/solutions/en/data/1-18CBI/index.html?solution=1-18CBI
    Regards.
    Josh L.
    Applications Engineer
    National Instruments

  • Problems of integrating Matlab functions in Labview

    Hi,
    Does anyone know how to completely integrate Matlab functions into Labview program without a copy of Matlab in the system when I run the entire program?
    Initially I used 'Mathscrip' node but I heard that it doesn't support Matlab toolbox.  Thus, I tried out the other option 'Matlab script' node. This node works well in implementing Matlab functions but it indeed requires Matlab installed in the system. 
    So in other words, how could I realize the full integration(as what Matlab script node achieves.)  without Matlab installed in the system?   
    Cheers,
    Nicholas 

    hi smercurio,
    So you mean that the Matlab script is no longer necessary in my case right?
    Could I just ask my colleague to compile his codes to matlab dll and I use the Call Library Function Node  instead of Matlab script to call it?
    About MCR, is it the correct source at the following link  http://www.mathworks.com/matlabcentral/fileexchange/5268 ?
    Sorry for those basic queries in Matlab as I have very little experience in it. lol... thanks a lot.
    Cheers,
    Nicholas 

  • LabVIEW Calling Matlab on PocketPC

    Does anyone know if it's possible to call a Matlab dll or script from a LabVIEW vi running on a PocketPC?  I searched the forums, but all of the posts seemed to be specific to a PC and not a PocketPC.
    Thanks

    This post really begs the question: do you have a version of MatLab for the PocketPC?  I have a new (Christmas) Pocket PC and I would love to be able to run matlab on it.  I have not looked for this, however, so could you give a little info about it?
    Thanks,
    Bob Young
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

  • Interface between LabView Executables and compiled MATLAB code

    Query: Does anyone have experience of calling compiled MATLAB functions from a LabView Executable?

    Hello
    Well, I am using some applications as you ask. Some calculus was done in matlab, so, now, it is compiled as dll an front end and other calculatiosn are in Labview. matlab dll are registered as activex, and so are called from labview. Integration is so good, tha some old matlab application was changed to Labview and matlab dll.
    I must to state that I am not the integrator. My part is only Labview. So, should you have further questions, I can pass this thread to the integrator company. I do not promisse answers.
    But it runs fine.
    Cheers
    Alipio
    "Qod natura non dat, Salmantica non praestat"

  • Generate pulse frequency with usb-6259 on matlab

    Hi,
    I would like to create a pulse with the ni usb-6259 counter via Matlab (R2007b). As Matlab Data Acquisition Toolbox dosen't support the access to the counter/timer of the 6259, I call 'DAQmxCreateCOPulseChanFreq' from the library. However, it returns a negative status indicating that the channel was not created. Can someone tell me why I have a negative status?
    Thanks,
    Miko
    Here is the code:
    % %load libraries nicaiu.dll,nidaqmx.h if not loaded
    clc
    if ~libisloaded('myni')
    disp('Matlab: Load nicaiu.dll')
    funclist = loadlibrary('nicaiu.dll', ...
    'C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include\nidaqmx.h', ...
    'alias', ...
    'myni' );
    end
    disp('Matlab: dll loaded')
    disp('')
    % Counter must be driven and read through 'c' function calls
    % Define variable for taskhandle
    taskh1 = uint32(1);
    % Create task
    [a,b,taskh1] = calllib('myni', 'DAQmxCreateTask', 'master', taskh1);
    % Create channel name for counter input edge count
    taskchans1 = ['Dev1/ctr0'];
    %define required properties for pattern generation
    DAQmx_Val_Hz = 10373; % a pre-scaled unit (aka DEFINE)
    DAQmx_Val_Low = 10214; % resting state, pre-define unit
    initialDelay = 0; % sec
    freq = 16000; % Hz
    dutyCycle = 0.5; % width / period. This ratio, combined with frequency, determines pulse width and intervals
    % Create channel: specify duty cycle and frequency
    nStatus = calllib('myni', 'DAQmxCreateCOPulseChanFreq',...
    uint32(taskh1), taskchans1, '', DAQmx_Val_Hz, DAQmx_Val_Low, initialDelay, freq, dutyCycle);
    if nStatus == 0 % channel created successfully
    disp('Success')
    elseif nStatus < 0 % error: channel not created
    disp('Error')
    elseif nStatus > 0 % channel created with warning
    disp('Warning')
    end
    Miko

    Thanks Peter!
    It indeed proved useful, thanks to the last comment (slastuka p.10).
    It seems that the input and output type depend on NIDAQmx version.
    Here is the code (that works for me), in case help someone else:
    clear all, close all
    clc
    if ~libisloaded('myni')
    disp('Matlab: Load nicaiu.dll')
    loadlibrary('nicaiu.dll', ...
    'C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include\nidaqmx.h', ...
    'alias', ...
    'myni');
    end
    disp('Matlab: dll loaded')
    % libfunctionsview('myni')
    % Counter must be driven and read through 'c' function calls
    % Define variable for taskhandle
    Taskh1 = [];
    % Create task
    [a,b,Taskh1] = calllib('myni', 'DAQmxCreateTask', 'Counter', Taskh1);
    Taskh1 = libpointer('voidPtrPtr',Taskh1);
    % Create channel name for counter input edge count
    Taskchans1 = libpointer('cstring','Dev1/ctr0');%Counter name
    NameChan = libpointer('cstring','');%Channel name
    %define required properties for pattern generation
    DAQmx_Val_Hz = int32(10373); % Units: Hz <-> 10373
    DAQmx_Val_Low = int32(10214); % Resting state: Low <-> Terminal is at a low state at rest. Pulses move the terminal to a high state.
    InitialDelay = 0; % Delay (sec) from the start call to the beginning of the pulse train ; this is currently set to 0.0 by default.
    Freq = 16000; % Hz
    DutyCycle = 0.5; % width / period. This ratio, combined with frequency, determines pulse width and intervals
    % Create channel: specify duty cycle and frequency
    nStatus = calllib('myni', 'DAQmxCreateCOPulseChanFreq',...
    Taskh1, Taskchans1, NameChan, DAQmx_Val_Hz, DAQmx_Val_Low, InitialDelay, Freq, DutyCycle);
    if nStatus == 0 % channel created successfully
    disp('Success')
    elseif nStatus < 0 % error: channel not created
    disp('Error')
    elseif nStatus > 0 % channel created with warning
    disp('Warning')
    end
     I don't know for the following, but at least I can create the channel.
    Miko

  • Included DLLs path, call library node

    Hi,
    somebody handed me a DLL I want to use (specifically, from compiled with
    matlab) in Labview. The problem is that the DLL has dependencies upon the
    matlab c math library functions.
    So in Labview I can add a call library node for the dll, but it still
    complains about not finding the matlab library functions. What do I need to
    do to let Labview know where I have these libraries stored?
    -joey

    It sounds like your LabVIEW code is successfully calling your .dll It is then the .dll's responsbility to find the files it needs, and ideally the documentation with the .dll or with Matlab should answer this question. After LabVIEW calls your .dll, the code in the .dll is the code in charge of what happens. There is a good chance that the .dll is only programmed to find the files it depends on at a given relative or absolute path which is no longer correct wherever you have copied it to.. if you control the code for the .dll, particularly the error message, this is a good reason to have the file not found error message explain where it was trying to look (i.e. be specific)
    If this program is something you just need to run and not distribute, maybe you should just
    browse for the .dll from the Call Library node in the location where Matlab creates it... if it doesn't even work there, you will definitely need to find out how the Matlab .dll is supposed to work.
    If you can call a .dll from Matlab, try moving it and then calling it from Matlab again, and check whether any Matlab environment path settings are being used or assumed in the .dll code.
    Good luck

Maybe you are looking for

  • [Wine] Sound card selecting issues

    Since a month or too, after one of my weekly updates, wine started to select the wrong sound card for its audio playback. Thus, alas, no sound in wine applications. When selecting the audio tab in winecfg, I get the following console output: fixme:mi

  • IMac only starts into Console mode

    Hi - I tried to follow the instructions in this link ( http://homepage.mac.com/james.clay/iblog/B894479528/C2040813928/E20070505184135/ index.html ), but since version -001 ("AirPort Base Station Update 2007-001")wasn't available anymore on Apple's W

  • Quantity Issue- Milestone Billing

    i am doing milestone billing, where the scenario is , i hav to bill the amount in 3 stages. 30-30-40. Here i am using the billing type F1 earlier when i was creating a invoice for the first time by default the system was taking total vaule of the inv

  • Importing Quicktime with Flash codec

    I wanted to put a Flash cartoon I made into my iMovie, so I published into Quicktime. It worked fine when I opened it in Quicktime but when I try to import it into iMovie the import progress bar flashes briefly then dissapears then after that nothing

  • BC 2.1 deletes Unsigned drivers, doesn't replace them.

    Just thought I'd pass along my experiences. It would appear that the XP version of the 'new' BC 2.1 is the same as the one on the MacPro 2008 install disc. I had installed the Beta nVidia drives after running BC the first time. When I ran the new dow