Matlab Script doesn't execute code

Hi
I'm using LabView 6.1 and Matlab 6.5. I have a VI that starts a simulator made in Matlab/Simulink. I need to execute a function in a matlab m file, and I'm using the Matlab Script node to do this. The problem is that the code only executes occasionally. Is there no guaranty that all code in Matlab Script is executed, or am I using it wrong?
Thanks
Petter

You may want to take a look at this Knowledge Base on NI's website. It providess an update for using Matlab 6.5 scripts with LabVIEW 6.x.
J.R. Allen

Similar Messages

  • Dynamically import .m file into Matlab Script

    I would like to dynamically load a Matlab .m file into the Matlab Script function in a VI.
    In other words, based upon a path to a .m file (control on the FP), load the .m file into the Matlab Script and then execute it.
    Does anyone know how to do this?
    Solved!
    Go to Solution.

    Hi RedSoxFanatic,
    It's not possible to do what you're asking.  However, I can think of a couple options that will give you the same behavior.
    1.  If you only have a few of your .m files that will be called you can use a case structure with these files already loaded.  The user can then choose which case to run.
    2.  You can have the Matlab Script Node run you particular .m file based on an input (number maybe), but this does also require you to have a predefined list of your .m files.
    Justin D.
    Justin D.
    Applications Engineer
    National Instruments

  • Matlab syntax errors are not caught and reported when code is executed in a LabVIEW Matlab script node

    I want to be able to catch errors that occur during the execution of Matlab code in a LabVIEW Matlab script node. According to my understanding of the documentation, errors of this type should be available at the "error out" signal point on the Matlab script node. I have noticed that even deliberately generating matlab syntax errors will not produce an error output. See the attached vi for an example.
    Attachments:
    matlab.vi ‏13 KB

    I ran your example VI and the is what I got in the Error Out cluster:
    "Code 1050
    Error occured while executing script. Error message from server: ??? This is an error
    . in matlab[1].vi"
    If you are generating custom error messages in Matlab I would suggest passing them back to LabVIEW through output variables in the script node.
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

  • MATLAB script in executable

    I made an exe out of a VI that uses a Matlab script. When I run the exe, I get a 1047 error (failed to send variable to script server) even though that error does not appear when I run the VI. I looked at the knowledge base document 1JNEPGU0 and did what it suggested, even though I shouldn't have to since I am on LabVIEW 6.1. I also am using the updated matscript.dll, per knowledge base document 300A6NDT (the VI did not run until I updated this.)
    My software is Windows XP, LabVIEW 6.1, Matlab 7.0.4 (R14)
    Thanks!

    Hi Nick,
    I think you are well aware that you indeed CAN interface with MATLAB 7.0 (R14) from LabVIEW 6.1 - that is part of what the KnowledgeBase 300A6NDT
    covers. Since you already got that working in the Development System,
    the issue must be caused by the fact that you are using an executable
    in stead of a VI. Did you follow the instructions specific for executables:
    "If using the MATLAB or Xmath Script Nodes
    in built applications you will need to also replace the appropriate
    DLLs located in the National Instruments\Shared\LabVIEW Run-Time\VERSION\script directory."
    If you already did that, we must look elsewhere for a solution. The
    following KnowledgeBase also covers an issue with executables and
    MATLAB:
    Why Does My Executable Hang When It Is Opened When I Use A MATLAB Script Node?
    If this doesn't work, please let me know the following:
    Are you running the executable on the computer that has the Development System installed?
    Is MATLAB open when the executable is called?
    What instructions  are you using to build the executable?
    Hope this helps!
    - Philip Courtois, Thinkbot Solutions

  • Matlab script of labview keeps executing multiple times,

    i have some code for serial communication in matlab , i want to use it in labview for easier and better gui design. for that i have used matlab script node in labview. it seems that labview keep executing the matlab script but i want labview to execute it only once.is there any way to do it?
    Solved!
    Go to Solution.

    i am attaching a vi file. this vi sends 'h' to the com1 continuously but i waant it to send only once.
    Attachments:
    forum.vi ‏7 KB

  • Error occured while executing Matlab script

    Hello!
    I want to run a Matlab script under LabVIEW, but there is always
    a error message which says "Error occured while executing script".
    Should I install Matlab on the same computer at first? if yes, do
    I need to configure Matlab under LabVIEW?
    Thanks!
    Le

    Yes No
    Eric P. Nichols
    P.O. Box 56235
    North Pole, AK 99705

  • Same code gives different results in Matlab Script in Labview and Matlab

    I am implemeting a Matlab code into a LabVIEW application using Matlab script. When I import the exactly same code to the Matlab Script in LabVIEW it gives a different result than it is in Matlab. This code is a simulation code including first kind bessel functions. Using LabVIEW 7.1 and Matlab R14 service pack 3.

    Labview 8.5
    Matlab R2009b
    Attached are the graphs produced by matlab script in labview and in matlab.
    The minimum of graph produced by matlab code is below 1 and that in labview is above 1.
    Thanks a lot for your reply.
    Sorry, I haven't quantified the "sometimes" yet. 
    Attachments:
    matlabsResult.jpg ‏29 KB
    LV.png ‏84 KB

  • HiQ doesn't execute scripts and command line commands

    I am running HiQ pro 4.5 on Windows 2000 SP 2. Whenever I enter a command line command, e.g. "1+1", HiQ reports "no error reported" and doesn't execute the command. When I enter the same command again, HiQ tells me that a semicolon is missing.
    When I try to execute a script, HiQ reports "Fatal Script error on line -1".
    Anybody knows this behaviour and how to get HiQ running normally?

    I do have the same problem.

  • ICal doesn't execute Automator Scripts

    Since I upgraded to Leopard my iCal doesn't execute scripts anymore. Normaly every day iCal executed a script to check for birthdays and send them a e-mail. Now I can't get this to work. No settings are changed as far I can see.
    Help!!! (I missed already a few birthdays... people hate me... ;-))

    Does it display any kind of error message? It may be that the location of the script has changed. It seems that iCal saves fixed paths to scripts and not aliases. This means that if the path to a script changes it won't run. Try to rename a script and then select it again in the event. You'll want to rename so that you can distinguish it from the previous script entry. iCal only displays the name of the script, not the path used by the alarm.

  • Executing MatLab script

    Hi guys!
    I'm using TestStand to log a bunch of data and save them as binary files. When the test is finished I would like to run a matlab script. At the moment I do this manually, just opening MatLab and changing the path that the script uses to find the particular set of binary files from the test.
    From what I understand you can't use the MathScript function with the base package.
    I don't require anything more than opening mathlab/running the script in the background at at certain point in the test. Could this be done by using a system call and just passing the path as a parameter from a LabView VI?
    Any ides to what is the best approach?
    Thank you for your time!
    Solved!
    Go to Solution.

    You'd be better off posting this question in the TestStand forum, since this is really a TestStand question. In fact, all of your other questions have actually been in the TestStand forum. As far as doing this using a LabVIEW VI, sure you could do it. The VI would contain just a couple of lines of Matlab code to call the script, I suppose. You could also use the Matlab COM server to call Matlab that way. That's how the LabVIEW interface works, so you can just cut out the middle-man, so to speak.

  • Matlab script in executable won't run

    I'm having trouble with getting a VI with a MATLAB script to run reliably, specifically when built into an executable.
    I'm using LV8.0, Matlab R2006a.
    The VI (not executable) runs properly when I start the computer fresh (i.e. just after a reboot)
    The MATLAB command window opens as soon as I open the VI.
    If I build an executable and run it, it works, so long as I haven't closed LabVIEW and the VI.
    If instead, I attempt to close out LabVIEW and run the executable alone, the MATLAB command window does not start, and the MATLAB functionality is ignored.
    I have updated all of my dlls, and I have checked the box enabling the ActiveX server (though I don't know what to name the server).  I have also read all the associated Knowledge Bases, and found their solutions did not apply.
    I also have intermittent issues running the VI once I have tried running the executable.
    If I make a change to my MATLAB script, I can get the VI to run again, but if it has failed once, the MATLAB command window no longer opens when the VI is opened.
    I can solve this problem by rebooting too, but it seems like there should be a better way.
    Any ideas?

    Hi tblir,
    Can you try to run and build into an
    executable one of the shipping examples (i.e.  MATLAB Script – Fractal.vi)?  Let me know if this exemplifies the same behavior.
    Ecleamus Ricks, Jr.
    National Instruments
    Applications Engineer

  • Doesn't execute my user exit codes.

    Hello Experts,
    I have created user exit ZXF05U01 to validate Tax Number1 field and activated. (txn fk02)
    Then Execute the transaction CMOD.
    Created a project ZFIAPVEN
    In "Enhancement assignments" added SAPMF02K as enhancement.
    Saved it.
    Then in the initial screen of cmod I've activated the project.
    Doesn't execute 'MODULE EXIT_KREDITOR AT EXIT-COMMAND.' When I ran the txn fx02 in debug mode it.
    Regards
    Naz

    I think I took the wrong path to validate the New Zealand specific tax number. Is it possible to set some rules in PRST1_005 in table T005.
    If this is possible then please pass me the steps description.
    Thanks.
    Naz

  • 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

  • Retrieving data from a MATLAB script node

    I am creating a VI that imports and manipulates arrays of data points and then plots them in Labview. When I run my Matlab script in Matlab there are no errors and all the assigned variables exist in the form that they should exist but for some reason Labview cannot retrieve all of them (they just show up as zeros). There are no errors in the script as far as I can tell. Do you have any idea what could be going wrong?

    Hi,
    You can use the MatLAB window opened by LabVIEW to debug your script.
    Check the values of your variables in the MatLAB window and try to find out where the data goes wrong. I've experienced many problems with LabVIEW MatLAB nodes on different PCs, and many times legal MatLAB operations would go wrong in the script node. You will need to find out which line exactly does your MatLAB code not executing correctly and try to modify the MatLAB codes from there.
    Hope this help,
    Dan

  • 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.

Maybe you are looking for

  • Cannot install itunes 7.1 in Windows Vista Home Premium

    I am getting this error when I try to install iTunes: "iTunes could not be installed because Visual Basic Script (VBScript) is not installed or has been disabled. Make sure VBScript is installed, turn off script blocking in anti-virus and personal fi

  • XI Integration Builder Security

    We need to access to XI Integration Builder and XI System Landscape Directory for internet use. In our system landscape the users currently access, for instance, the portal by an iisproxy and access SRM by an ITS wgate. The server with iisproxy and t

  • Best way to set up a second/family iPad?

    I am using a new Air2 as my main iPad and now want to setup my iPad2 as a general usage iPad that anyone in my house can use for things like surfing the web and viewing a baby monitor, etc. I'm trying to figure out the best way to set it up, I'm not

  • How to change domain name on Windows 2003 running Exchange 2007

    Hi all, I have a windows 2003 server running Exchange 2007.  I am wanting to rename the domain, however when I search the web for the process to perform a rename of the domain I see "The domain rename operation is not supported in Microsoft Exchange 

  • How to delete public link to CC folder?

    how to delete public link to CC folder?