Compiling VIs with Matlab scripts

Hi everyone,
I need to build application for a VI with some matlab scripts included in the block diagrams using the Matlab scripts node. I've been searching for related topics and I'm hoping someone can help me understanding the big picture here.
Background info: I'm using LV2012, Matlab 2013. I DON'T USE MathScript RT Module.
Question:
1. To build a stand-alone application for the use on a PC with Matlab software but no LabVIEW, do I just simply build the application in LabVIEW project?
2. To build a stand-alone application for the use on a PC wthout Matlab and LabVIEW, do I need to create a DLL from Matlab and modify my VI to use "Call library function node" and then build the application in LabVIEW project?
Thanks for answering my questions!

Question:
1. To build a stand-alone application for the use on a PC with Matlab software but no LabVIEW, do I just simply build the application in LabVIEW project?
Yes,  Assuming it is a windows machine and the Licensed version of Matlab is version 6.5 or later the LabVIEW Run-Time engine knows how to call the Matlab script server through Active X.
2. To build a stand-alone application for the use on a PC wthout Matlab and LabVIEW, do I need to create a DLL from Matlab and modify my VI to use "Call library function node" and then build the application in LabVIEW project?
You cannot use a Matlab math script node without a licensed version of Matlab 6.5 or later resident on the target and the target must support Active X so, Windows only.
Jeff

Similar Messages

  • Intermittent issues with Matlab Script in LV2012

    I'm having some intermittent issues with the Matlab Script in LV2012.  I'm running Windows 7 64 bit, and my Matlab is 2013 64-bit.  I've tried the suggestion here:
    http://digital.ni.com/public.nsf/allkb/8BEBC0C86541224286257AF300561B5E
    I tried this but it didn't work for me. 
    I've also looked at this:
    http://digital.ni.com/public.nsf/allkb/2B3FF46C8512C4F786256CF30071BE53?OpenDocument
    In one of my .vi's if I change 2 of the 3 input variables to the complex type, it works.  It seems to be insensitive to the data type of the first input variable.  In another .vi this trick doesn't work at all.  The fix given in the link is to update the .dll, but this seems to be old news as the .dll in my directory is newer than the one referenced in this link.
    The other funny thing is these scripts worked fine on Friday afternoon, but were throwing this error this morning.  I've closed and reloaded both Labview and Matlab, but that didn't fix the issue.
    Are there any new fixes for this issue that I haven't been able to find?
    Thanks,
    Doug

    Doug,
    If you have a service contract feel free to call in to the support line and you'll be able to work with someone on the phone. That'll be the quickest way to resolution.
    Feel free to send me a PM if you wish and I can take a look at the code and test it on our machine. 
    Notes for Branch AE:
    Please reply to This Post within 24 hours
    The US AE is expected to reply to all of your posts within 24 hours. Having this expectation will keep the escalation moving quickly and toward a fast resolution.
    You can also use other communication channels: Phone, Sametime, Lync,etc. to discuss the issue with the US AE. This can help with troubleshooting and quick diagnosis of the issue.
    Click here to provide kudos for a post on this page

  • Error 1050 with matlab script

    Hi , i'v built an vi which sampling saving and playing audio files , i've also added matlab script for data analysis.
    the script tested in matlab and in matlab works great , when im trying to use it in labview i'm getting an error while the matlab sciprt executing . "Error using griddedInterpolant ....."
    i think that the error occures whe trying execute the command : "Sigitp = interp1(clptv, clpsig, tv, 'linear'); "
    moreover i cant figure how to read the saved filed when the loop is finished.
    I cant figure out what is the problem .
    here is the vi : 
    i've also included the vi 

    Cobmetal wrote:
    Im novice to labview , and im learning a lot from NI community , thank you for your suggestion , i will go over it , and try to learn the proper way to implement such tasks in the future.
    Thank You.
    That's excellent!  I believe that if you truly understand dataflow, you will see why your solution isn't the best one.  ASK QUESTIONS IF YOU DON'T UNDERSTAND SOMETHING.  I put that in bold caps because we are here to help you understand and get better. 
    Example:
    "According to what I learned about dataflow, I think this part of my solution mentioned above can look like this.  (Upload picture.)  Does that seem right to you?"

  • Labview interaction with MATLAB

    Hi,
    I'm working with Matlab script in labview.
    i have both Matlab6.5 and Matlab7.0 on the PC. 
    i have changed the matscript.dll file as requested to work with Matlab6 or later.
    i need to work with the Matlab7.0 but the Labview is going to the Labview 6.5 always.
    how can i direct Labview to work with the Matlab7.0 (without uninstalling the 6.5)??
    Regards,
    Idan Wexler
    Analog Cells Team
    Texas-Instruments -BC-IL
    e-mail: [email protected]
    Tel: 972-9-970-6743
    Fax: 972-9-970-6430
    Mailing address: 8 Hasadnaot St. 3rd floor, Herzelia 46766, Israel

    Hi Idan,
    perhaps this can help you:
    Please make a backup of your registry before trying this!
    - open regedit
    - go to HKEY_CLASSES_ROOT\Matlab.Application\CLSID and look at the ID provided
    - Cross reference that key to HKEY_CLASSES_ROOT\CLSID and see which executable is getting run
    - Change the CLSID in the first path to reference MATLAB 7.0
    - close regedit
    Regards,
     Andi
    ~~~ Logic is a systematic method of coming to the wrong conclusion with confidence ~~~

  • Error 1048 Matlab Script depends on string length

    Using: Labview 8.2, Matlab 2007a, Windows XP (AMD X2 4200+ 3GB RAM).
    I'm having an issue with MATLAB script server, Error 1048 failed to get variable from script server.  I've read the forums, but most posts are years old and don't address variable size issues.  I have no problem with these strings inside the MATLAB command window.  I'm somewhat inexperienced with LabView, so maybe this VI could have been simplified.
    I'm writing data files with a tab header, using MATLAB to perform some operations on data (I have a library written to do certain things and can't really spend the time to recode in Labview).  When I try to pass out the new header string, I get error 1048 only when the string length goes above a certain size range.  I have iterations because I want to process hundreds of files in a similar fashion to this VI.
    Header length ~ 1300 chars has always been fine, regardless of number of iterations within the VI.
    Header length ~ 2600 chars presents some errors; not deterministic.
    Header length ~ 5200 chars has many errors; not deterministic.
    Header length ~ 7800 chars has many errors, fails almost all the time.
    Also, timing delay after reading in the file seemed to do nothing to help.  Pausing at the end of the MATLAB script did not seem to help. Clearing MATLAB/restarting LabView did not seem to help.  Is there a way to catch variable-specific errors from the script window?  Notice that the output variable is not cleared when it fails to be obtained from the MATLAB window.  I could wrap the whole thing in a while loop until there are no errors, but that doesn't help when the length is so large none of them succeed.   I can split the string inside matlab, but I'd have to create n strings and then concatenate them outside, which still gives me a lack of scalability.  Is there any better way to handle this kind of non-deterministic error?
    Thanks very much for reading.
    Attachments:
    header6001.txt ‏8 KB
    Matlab Script Server Test1.vi ‏38 KB
    header1001.txt ‏2 KB

    Does NI monitor these forums for bug reports to fix?  Here's a non-scalable hack solution I mentioned earlier, creating n string outputs and concatenating them in Labview.  I've checked this in Matlab using the code below.  I've included the VI if anyone has the same issue and wants it.
    Note that I chose to throw the size error if the string is too large for the n you choose.  I prefer this to trying to check the string output to see if it was truncated.
    hcols = size(hstring,2);
    for k = 1:8
        hvar = strcat('h', sprintf('%d',k));
        if( hcols >  k*1000 & k < 8 )
            hcom = sprintf('%s = ''%s'';', hvar, hstring(1, ((k-1)*1000+1):k*1000 ));
        %if size < k*1000, or we're at the end with leftovers, copy what's left
        elseif( hcols >= (k-1)*1000+1  &  (hcols <= k*1000 | k == 8 ))
            hcom = sprintf('%s = ''%s'';', hvar, hstring(1, ((k-1)*1000+1):end));
        else
            hcom = sprintf('%s = '''';', hvar);
        end  
        eval(hcom);
    end
    %Matlab validation code.  Do not use strcat, as it will chop tabs at the endpoints.
    newh = sprintf('%s%s%s%s%s%s%s%s', h1, h2, h3, h4, h5, h6, h7, h8);
    strcmp(hstring, newh)
    Attachments:
    Matlab Script Server Test2.vi ‏40 KB

  • Compiler Error with simple vi using MatLab script nodes

    While attempting to build a simple vi to test the capabilities of LabView's interface with MatLab, I received a compiler error message that said I should report the problem to National Instruments Tech Support. The error said, "reference to undefined label from: refPC=0x41C." I've attached the vi that created the error. I am using LabView 7.0 on a PC running Windows 98.
    Attachments:
    Compliererror.vi ‏11 KB

    I don't know if this will help your problem, but there is a fix for some problems with LabVIEW 7.0 and Matlab:
    http://digital.ni.com/public.nsf/websearch/4475BC3CEB062C9586256D750058F14B?OpenDocument
    Good luck,
    -Jim

  • How can I compile all functions, procedures and packages with a script?

    I need to compile all functions, procedures and packages of 5 schemas (users) with a script.
    How can I do it?
    Thanks!

    you can create a script to select all invalid objects in those schemas Since Oracle 8 introduced NDS this approach has struck me as a trifle old fashioned. It's much simpler to loop round the query in PL/SQL and use EXECUTE IMMEDIATE to fire off the DDL statements. No scripts, no muss, no fuss.
    Having said that, the problem with this approach and also with using DBMS_UTILITY.COMPILE_SCHEMA is that they do not compile all the invalid objects in dependency order. This may result in programs being invalidated by the subsequent compilation of dependencies. This is due to the introduction of Java into the database.
    The UTLRP script is much better, because it (usually) avoids cyclic references. But you still may need to run it more than once.
    In general it is better to avoid sledgehammer recompilations (like DBMS_UTILITY.COMPILE_SCHEMA, which starts by invalidating all the objects). If we have twenty invalid objects, nineteen of which are dependencies of the twentieth, we actually only need to recompile the master object, as recompiling it will trigger the recompilation of all the others.
    Cheers, APC

  • Question on model crashes (compiled with Matlab 2013b and Veristand 2013)

    These models were compiled with Matlab 2010a and Veristand 2010 and when I deploy them to RT target with Veristand 2013, everything works correctly.
    Now I compiled the same models with Matlab 2013b and Veristand 2013...they are successfully deployed to the same RT target but when I start the model (set model command to 0), the RT side crashes.
    The strange thing is that I found if I set the initial state of model to running, this crash won't happen but when setting initial state to paused then manually set model command to 0, RT machine crashes immediately. Have any one come across the similar issue? I feel it's something to do with the initial condition but wonder why it doesn't happen when compiled with Matlab 2010a and Veristand 2010. 

    That behavior definitely sounds odd. I would expect models that worlk in previous versions of VeriStand to work with newer ones as well.
    With that said several other things have changed in the interum between VeriStand 2010 and VeriStand 2013.
    I see you have already contacted us through a service request, we will continue troubleshooting there for the moment.
    Craig H. | CLA | Systems Engineer | National Instruments

  • Using a 3D matrix with a matlab script block

    Hi all of you,
    it is possible to input a 3D matrix (e.g. 10x4x20) to a matlab script block or you have to unfold this data in a 2D array?
    Do you know what i have to do to input directly a 3D array (array of real numbers) to a matlab script block.
    P.D.; I'm using labview 7.0 and matlab 6.5
    Thank you very much
    Larson

    Hi,
    as far as I know there is only the possibility to have an input for a
    2D array to matlab scriptnode. Thus you should convert your 3D data to
    2D in LV and reconvert it in your matlab code into 3D.
    When you select 3D data as an output of a script node it automatically
    appears as 2D (but no data will be lost). So when you have to use it in
    LV again as 3D data, what you have to do is reconvert it back from 2D
    to 3D.
    Hope this helps!

  • Running Matlab Scripts in Parallel

    I have several MATLAB scripts running in my LabVIEW VI via MATLAB script nodes, and one of them in particular slows by program down considerably.  It dawned on me that I could just take the slowest commands in the script, place them in a script node running a separate VI, and run the two VIs in parallel.  It seems it doesn't work that way, though - my main program runs a little faster than it did before, but I only get a major speed increase when I stop the second VI.
    I realized a long time ago that two VIs running in parallel share the same MATLAB environment and can even address the same variables, but it never occurred to me that I couldn't actually run two MATLAB scripts at the same time - and that seems to be the case.
    What would be the best way around this limitation?  Is there some way I can force the two VIs to use separate MATLAB environments?  (There's plenty of resouces available on the computer, so I'm not particularly worried about inefficiency.)  Would compiling the VIs or compiling the scripts somehow help?

    What is your LabVIEW version. How complicated is the matlab code? Would it be easy to rewrite it in plain LabVIEW?
    Have you tried to see if it runs in mathscript instead?
    ( I am not sure about performance comparisons and I also don't know if mathscript can run in parallel.).
    How many CPU cores do you have?
    LabVIEW Champion . Do more with less code and in less time .

  • Matlab script node for real time purpose

    Hi!
    We are trying to control in real time the frequency of a vibration motor with a voltage signal proportional to EMG activation.
    Our EMG sends data to a LAN port and we read them in Labview using the UDP Read function.
    We created a VI which reads data from UDP connection, parses the header and does the decoding (according to the data type of our EMG device, TMSi Porti).
    Every sample read from UDP port is passed to the Matlab script node which implements a Bayesian filter which returns a value (MAP) used to control the vibration frequency.
    The problem is that this operation is extremely slow...(about 15 seconds!!) and we need it to be real time!
    We tried also a simple MA filter and the delay is reduced to around 2 sec, so we think that the major problem is in the Matlab script node.
    We wonder if this delay is due to the call of an external code (Matlab) or to the complexity of the Matlab code itself.
    Do you know how to improve the performance of this VI?
    Thank you!
    Serena
    Attachments:
    EMGreceiver+Bayes.vi ‏54 KB

    Serena
    I noticed that your code also have LabVIEW MathScript RT code. Have you tried to replace the Matlab scriptnode with it? The MathScript Node compiles the script natively into G function and avoid transfering information between programs.
    If this does not speedup your application, please attach the subVIs and test data that allow us to reproduce the problem and performance. Also, what is the version of LabVIEW that you are using? If it is before LabVIEW 2009, then I would strong recommend update to that version.
    Barp - Control and Simulation Group - LabVIEW R&D - National Instruments

  • I cannot run the matlab script node in the labview

    Hi there,
    My LabVIEW version is 8.5, and matlab version is R2008a.
    I wrote a simple matlab code, like x= 1, y = x*2. Then I tried to put them into matlab script node in LabVIEW.
    However, when I ran the program, I couldn't run and Labiew show some error. 
    Then I tried the method talked before on this forum. Please see the following link.
    http://forums.ni.com/ni/board/message?board.id=MathScript&thread.id=571
    I followed the instruction and open the "command prompt," type some commands then I could run the program, and simultaneously, the LabVIEW program open "Matlab command line window" and run my labview code. However, if I didn't use the command prompt, the  "matlab command window" will not be opened by running the labview program. It would just show some error. And even if I turn on the matlab program in advance, I still couldn't run the labview program.
    Is there any effecient way to deal with this problem without using "command prompt?" Because I try another PC with both matlab and labview installed on it, I "can" run my simple matlab script node on it, and it will open the matlab command line window automatically by running my code. Therefore, I thought there might be some software linking problems in the previous PC I used . Do you have any ideas?
    Thanks in advacne.  

    Hi, and thanks for the post! I hope your well today.
    This may help,
    MATLAB® version 2006b (7.3) and version 2008a do work with LabVIEW
    8.20. This problem can occur if a new version of the MATLAB® software
    is installed along with a previous installation, which is then
    uninstalled. The uninstallation of the older MATLAB® software results
    in removing the ActiveX/COM components LabVIEW uses. This can cause the
    MATLAB® script node in LabVIEW to stop working. There are three
    solutions to this problem.
    Uninstall the MATLAB® software and reinstall it. This should install the necessary ActiveX component.
    Restore the MATLAB® automation server. Browse to the \bin directory (e.g. MATLAB\R2006b\bin) and type matlab -regserver ,
    which will reset the registry settings and start the server. The server
    can then be closed and the MATLAB® script node will work properly again
    in LabVIEW. LabVIEW may need to be restarted if VIs are open that
    contain MATLAB® script nodes.
    Leave both versions of the MATLAB® software installed.
    MATLAB® is a registered trademark of The MathWorks, Inc. Other
    product and company names listed are trademarks and trade names of
    their respective companies.
    Did you have an older version of MATLAB before 2008a?
    Kind Regards,
    James.
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!

  • Matlab script image support?

    Hi there,
    I'm trying to use the imread function in the matlab script node to translate an 8-bit image into a intensity-value matrix. It works in normal matlab, but not in the node. I can't find the imread function in any of the labview help menus, so I was wondering if labview supports that function at all. If not, does anyone have any suggestions for automating getting the image into matrix form? Thank you,
    Stephanie

    Hello Stephanie,
    Are you using the same script in the node as you use in the MATLAB® software?  What is the error returned by the node?  Are you running the VI on the same machine where you tested the script in the MATLAB software?  The imread function does seem to be part of the Image Processing Toolbox, so you will need to ensure that this toolbox is installed on any machine that you intend to use to run your VI.
    The LabVIEW MathScript node is a textual node and its syntax is generally compatible with the m-script syntax used by other technical computing software.  Jeff is correct in that LabVIEW MathScript does not currently support the imread function.  However, it will likely be added in a future version of LabVIEW.  If you are looking for a solution in graphical code, LabVIEW does provide some VIs for reading and writing PNG, JPEG, and BMP files.  You can find the VIs in the Programming >> Graphics & Sound >> Graphics Formats palette.  You can then use the Unflatten Pixmap VI to get a matrix representation of your image.
    National Instruments also produces a Vision Development Module for LabVIEW that includes more advanced image acquisition (IMAQ) and image processing functionality.  This module is more for industrial and scientific use than for duplicating what might be provided in desktop image manipulation programs.
    MATLAB® is a registered trademark of The MathWorks, Inc.
    Grant M.
    Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments

  • How to open an lvm file in MATLAB Script Node

    Hello everyone
    I am using LabVIEW 8.0 in order to acquire a signal, and I chose to save the signal's data with "Write to Measurement File"
    Here is the problem, later on I am using a MATLAB script on the data, but the problem is that the MATLAB can't read the lvm file, because it doesn't have a txt ending.
    So my question is this : is there any way I can convert in LabVIEw the lvm file to txt ???
    Thanks ,
    Lavi
    Attachments:
    Single Session 19 04.vi ‏197 KB

    Edit: Sorry about the double answer on the .lvm file. Posted at the same time as previous answer.
    The .lvm file is a text-based file. Form the online help for LabVIEW :
    Use text-based measurement files (.lvm) to save
    data that the Write To
    Measurement File Express VI generates. The text-based measurement
    file is a tab-delimited text file you can open with a spreadsheet application or
    a text-editing application. In addition to the data an Express VI generates, the
    .lvm file includes header information about the
    data, such as the date and time the data was generated. LabVIEW saves data with
    up to six digits of precision in a .lvm file. Use
    binary measurement files
    (.tdm) to exchange data with higher precision.
    A few comments regarding your code:
    Learn to stop using sequence frames. This is typical for someone coming from a text-based language programming environment. This is not a personal knock on you, just a pointer. For example, instead of using the "Wait (ms)" function you can use the "Time Delay" VI. That has error in/error out clusters which will allow you to chain VIs. In the bottom part you can eliminate the sequence frame that you're using the parallel port write to the following:
    which is much cleaner and easier to read.
    The loop where you're reading data is pointless. It is set up to run only once, so what's the purpose of a loop?
    You do not need to place all objects inside a sequence frame and then place the sequence frame inside the loop. This is redundant.
    Message Edited by smercurio_fc on 04-19-2007 09:26 AM
    Message Edited by smercurio_fc on 04-19-2007 09:27 AM
    Attachments:
    Example_BD.png ‏5 KB

  • Possible threadsafe issues using Matlab scripts?

    Hi all,
    I'm developing an application in Labview 6.1 that makes extensive use
    of Matlab scripts.  The application executes the same set of
    scripts for multiple data sources, and keeps track of the inputs and
    outputs for each data source separately.  I've been noticing that
    the application produces the correct results when running only one data
    source, but that the results are often incorrect when I run it against
    multiple data sources.
    I've done some investigation, and have found that all Matlab scripts
    share a common memory workspace in Matlab.  That is to say that if
    I have ScriptA that takes variable X as an input, and ScriptB that does
    not, ScriptB nonetheless has access to variable X in its workspace
    (from the last time ScriptA was called).  This doesn't pose a
    problem to me directly, but it has made me wonder if there are
    potential threading issues in the scripts.
    Consider the following scenario with one script and two data
    sources.  I'm wondering if this scenario is possible in Labview:
    1.  Thread1 calls ScriptA, passing data from SourceX.
    2.  During Matlab execution (somewhere in the middle), Thread1 is suspended.
    3.  Thread2 calls ScriptA, passing data from SourceY (data have the same variable names, since it's the same script).
    4.  Thread2 finishes ScriptA execution uninterrupted with SourceY data.
    5.  Thread1 is reactivated, but now the Matlab workspace data has
    been replaced with SourceY.  So, Thread1 started with SourceX
    data, but finished with SourceY data.
    6.  An incorrect result for Thread1 is produced, because the wrong data was processed.
    Clearly I could get around this problem with a semaphore, but first I'd
    like to know if this scenario can even happen.  Are Matlab scripts
    treated as atomic operations in Labview, or can the threads be
    suspended midway through execution?
    Thanks for your help!
    cjb

    Hello,
    No. LabVIEW will definitely not compile a VI while it's running - I think that would be, even conceptually, impossible.  In fact, some properties (accessed via property nodes) are not editable at run-time for basically that reason, that a recompile would be necessary in order for the affect to take place, and the recompile can't take place at run-time!
    It is indeed strange behavior, particularly because it is intermittent (which does hint at a threading issue, or some factor outside the development environment).  Can you try moving the initialization to LabVIEW?  I have attached an example of a so-called functional global variable (a simple code module in this case).  It has two "states" (which are cases) - one is initialize and the other is the "usually executing case."  The initialize case is used to initialize the shift register to an array of 50 doubles, where the other case will compute the running average, min, and max across the 50 most recent random numbers generated.  The 50 data point code module.vi is the code module, and it is called by Use 50 data point code module.vi.  When you run Use 50 data point code module.vi, be sure to toggle the initialize boolean so that the initialize case executes once to allocate and initialize an array with 50 elements; when you toggle it back then it will execute the other case on each iteration, and begin computing the statistics noted by keeping an array with the 50 most recent random data points generated.
    I hope this helps and that you are able to incorporate a similar code module into your application to avoid the intermittent errant behavior!
    Best Regards, and feel free to post again with updates!
    JLS
    Best,
    JLS
    Sixclear
    Attachments:
    Use 50 data point code module.zip ‏27 KB

Maybe you are looking for

  • Extremely Disappointed with Droid Razor M

    I have had a Droid 2 for over two years and recently the screen began doing weird things by intermittently not responding to  touch screen input or by touching one thing and another untouched started.  OK, I still was happy with the old Droid 2 until

  • Weather not showing up in notification center if iOS 6

    Does anyone know how to add it?

  • CS5, Mavericks OS, Pshop crashes on print settings, Canon iP4820

    New Mac, on Mavericks OS: Photoshop CS5 will not print to Canon iP4820, quits every time I click print settings. Will print low quality.

  • TRACE file question

    I traced a user session against our TEST database to try and find out why an error is occuring. That trace file was quite large, with several queries showing up as going against SYSTEM tables: select /*+ index(idl_sb4$ i_idl_sb41) +*/ piece#,length,p

  • JSP attributes

    What are the attributes of JSP?.This is the question asked to my friend in an interview.Please give the answer in detail.And the links where we can the complete solutions for problems like this