Using '!' in matlab script

It seems unable to invoke the '.EXE' file in the matlab script node.
In my matlab code I use '!' to invoke a .exe file, it can be execute in matlab, but when I copy the same code to labview(matlab script node), it does not work
the error messages are
LabVIEW:  Error occurred while executing script. Error message from server: Warning: Name is nonexistent or not a directory: D:\Wastewater_experiment\programCodes\DymolaFiles.
> In c:\matlab6p5\toolbox\matlab\general\path.m at line 116
  In c:\matlab6p5\toolbox\matlab\general\addpath.m at line 88
< c:\matlab6p5\bin\win32\dsu.txt created.
... Error message from alist
Error opening file "dsin.txt": No such file or directory
??? Error using ==> load
Unable to read MAT file temp.mat: not a binary MAT file.
Try LOAD -ASCII to read as text.
Error in ==> C:\dn\programCodes\initload.m
On line 43  ==>      load temp
Error in ==> C:\dn\programCodes\operatingPoint.m
On line 17  ==> [x_init, x_name] = initload; % loads initial conditions from txt-file 'dsin.txt'.
. in labviewmatlab.vi
I am sure I have add all the path. and If I just run the code
! alist -a dsin.txt dsintest.mat
in matlab script node. There is no errors but it can not be execute.
This alist.exe file is from 'Dymola' to transfer the 'txt' to 'mat'.
How can I do with this error
Attachments:
labviewmatlab.zip ‏52 KB

Sorry
The problem have solved.
When I invoke .txt .mat .exe in LabVIEW matlab script node, this files should be under '.../matlab' path. I do not kown why it is not '.../matlab/work'.And 'addpath' is useless except to 'invoke .m' files.
It can work now.

Similar Messages

  • Creating a random noise (Gaussian) using Matlab Script

    Hello,
    Since I only have Labview 6.1 base, I can't use the white-noise generator in Labview. I'm thinking of using the Matlab Script. I have Matlab 2006R installed in the same computer. However, I tried running the program and nothing happened (I used the help example "a=rand(50);surf(a)" in the Matlab Script.
    Why it's not calling the Matlab, or is there a better way to create a Gaussian distribution in Labview 6.1 Base?
    Thanks a lot!

    Hello,
    Why are you unable to use the Gaussian White Noise VI in LabVIEW 6.1?  It is under the Analyze >> Signal Processing >> Signal Generation palette.  I have attached a simple VI that illustrates creating a matrix.
    If you wish to use the MATLAB® script node, let's first make sure it is working correctly.  Try opening one of the LabVIEW shipping examples.  Browse to <LabVIEW>\examples\scriptnode and open "HiQMATLAB_Fractal.llb."  Then open "MATLAB Fractal.vi."  Run the VI.  Do you get any error windows that pop up?  If not and you see a picture of a fractal appear, then the connection to the MATLAB software is working correctly.  In your VI, try creating an error out indicator from the MATLAB script node and see if any errors appear.
    If you do see an error in the shipping example, it means there is a problem with the software connection.  Make sure that you have launched the MATLAB software at least once after you installed it.  This will set up the necessary connection information.  Then launch LabVIEW.  If this isn't the issue, we could try manually restoring the server commands.  Make sure LabVIEW and the MATLAB software are not running.  Go to a command prompt, browse to the MATLAB bin directory (e.g. MATLAB\R2006b\bin), and type
    matlab -regserver
    Quit the instance of the MATLAB software that appears and launch LabVIEW.  If this also fails, please post again with any error information you receive.
    Also, the rand function in your script will not generate a Gaussian distribution. You will need to use the randn function instead.
    MATLAB® is a registered trademark of The MathWorks, Inc.
    Grant M.
    Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
    Edit: For some reason, I am unable to attach the VI.  I have included a picture instead.
    Message Edited by GrantM on 08-08-2008 02:50 PM
    Attachments:
    Gaussian Matrix.png ‏35 KB

  • Using matlab script block

    Hello!
    I'm using a matlab script block and I have a problem that i don't how to solve it,
    I want to import a column that in matlab is cell array or char array type. When you create an output in matlab script block you have to specify the data type....I choose string, but with this option you can only import one string....and I want to import a whole column.
    Someone knows how I have to do to import this data type? I have to do some changes to the data from matlab or I have to use some especific block in labview to adapt the data.
    Please help me!!
     Thanks!!!

    Ooooppss!
    My computer is crazy....sorry.
    I'm near to solve my problem...
    The problem is that I have a column of strings like this
    str=['labview'
            'labview2'
           'labview3'
            'labview4']
    I use the double command but the byte array to string block only converts me an element, do you know is exist another block to change all the elements.
    I've tried to do with a for loop block....using an index array and changing with i the index element, but it doen'st work.
    You have some idea?

  • 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

  • How to use a MATLAB license with password peotection?

    I am using a MATLAB network license, which is password protected, so when I use a MATLAB script node LabVIEW can't load the proper MATLAB license and fails.
    How can I submit the username+password info to LabVIEW?

    Hello malosh,
    Unfortunately the functionality is not in place for LabVIEW to pass your username and password into MATLAB for you. Is it possible to log into MATLAB and then run your LabVIEW application?
    If none of these suggestions help, or if I�m not correctly understanding your issue, please reply with comments or answers to the discussion above and any additional information that may help, and I�ll be happy to look further into it.
    Have a nice day!
    Robert Mortensen
    Applications Engineer
    National Instruments
    Robert Mortensen
    Software Engineer
    National Instruments

  • Variables not correctly sent to Matlab script server

    When using a Matlab script node in my LabVIEW code, I've noticed that variables are sometimes improperly sent to the script server. What happens is an m-by-n matrix in LabVIEW arrives in Matlab as a 0-by-n or 0-by-0 empty matrix. Typically the affected matrices are large -- 500 to 20,000 elements.
    Unfortunately, we haven't been able to recreate the error intentionally. On the other hand, when the error does occur by chance, it frequently continues to show up until the system is rebooted.
    This error has appeared using the same code on multiple systems, all of which are running Matlab 6.1 and LabVIEW 6.0.2.
    If anyone has encountered similar problems or has any insight into this problem, your help would be
    greatly appreciated.
    Zach Lerner
    OnWafer Technologies, Inc.

    I encountered this problem several times too.
    I passed a 'real vector' of size ~80 to a MatLAB input node, and it turned out to be a 0-by-0 empty matrix in MatLAB. This happens nearly every time after I reboot the computer.
    What I do is first to find out which variable is empty (from the MatLAB command window). Then stop the VI and rewire that input node.
    p.s. I have LabVIEW 6.0.2 with MatLAB 6.0.
    Dan

  • 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

  • Undefined output Matlab Script

    Hi guys,
                 I have some problem in using the Matlab Script. Currently, I have defined my output variable but however, the error kept prompting that there is undefined output. I wonder what is exactly the problem and how could I resolve it? Thanks a lot for assistance and sincerely appreciated.
    Rdgs
    kengkc
    Solved!
    Go to Solution.
    Attachments:
    error.PNG ‏109 KB

    Hi,
    Refer to this great KB which explains why you are getting this error message.
    Hopefully this helps.
    Regards.
    Steve M.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Vidéo-t'chats de l'été : présentations techniques et ingénieurs pour répondre à vos questions

  • 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

  • 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

  • Matlab script

    Hi everyone.
    I have a m.file in matlab used to simulate an optical scheme characterized by different parameters.
    I
    need  to combine different values of these parameters in order to
    obtain a kind of calibration. To do this I though to use labview
    creating a number of for loops to change the value of each parameter.
    Using the matlab script tool in labview the simulation runs ok.
    To
    change one parameter, for example Alfa_laser,  I created an input
    linked to the control and attached to the script. At this point, the
    simulation does not work.... and  I don't know why!!!!
    Someone can help me
    Thanks
    matomato
    Attachments:
    simulator.vi ‏51 KB

    matomato wrote:
    To
    change one parameter, for example Alfa_laser,  I created an input
    linked to the control and attached to the script. At this point, the
    simulation does not work.... and  I don't know why!!!!
    Someone can help me
    You have no inputs for the script node, so there is no link. All that you have is an output node tied to an array indicator. That's probably why the simulation doesn't work. Also, you have no loop. Do not use the "Run Continuously" button if that's what you're trying to do. 
    To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

  • 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

  • Matlab scripts that function properly when run in matlab generating errors in labview

    Hi, I'm running LabView 7.1 and trying to use some matlab scripts in my lab view script.
    The code runs fine in matlab, but when I run it in lab view I get errors as follows:
    "LabVIEW:  Error occurred while executing script. Error message from server: ??? Error using ==> mrdivide
    Matrix dimensions must agree.
    Error in ==> extract_inl_NI at 46
     in array_test.vi"
    There is no division in line 46 (in fact it's a blank line).  Are there syntax changes that I may not know?  Or perhaps a way to compile my code to ensure it runs correctly?

    Hello,
    Can you post your code (VI) here, or better yet a simplified version of it which still causes a problem.  If you can also post a simple version which functions as you expect, that would be nice, but it sounds like the plotting problem is intermittent.  This should work, per the following document, but perhaps there's an issue:
    http://digital.ni.com/public.nsf/websearch/57FE03DA9C357E9486256A0D00739CA6?OpenDocument
    Hopefully after seeing the code I will have more ideas about what may be going wrong.  As a final thought, are there any parameters to the plot function which can be passed to make it show the plot or make it the active window... could this be a very strange UI feature?  I guess it will make more sense when I see the VI(s).
    I look forward to your repost!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Matlab Script in LV 8.0 for 'SIM Command'

    Dear all
    I have problem using Matlab Script in LabVIEW 8.0 for 'SIM(Model, Final Time)' command.
    1. Does Matlab Script Server supports all the functions in Matlab 7.0.1?  I runned 'SIM(Model, Final Time)' on the LabVIEW Script, but no results obtained. It is supposed to get a figure output there.
    2. If I run some function in Matlab Script with input parameters. Do I have to set these parameters in Matlab Script of LabVIEW as 'Input' or I can set them in Matlab Workspace first then apply them directly. Since some of my parameters are classified as structure class. They won't allow me to use them in Script as 'Input'.
    Thanks for your help!

    Good morning,
    Thank you for posting. 
    I believe that you are using the MathScript node, but I am a little uncertain:
    If you are using Mathscript, you do not need to do anything
    with any ‘server’, but the particular function you request may not be
    implemented.  Which type of node are you
    using?  If you are using Mathscript, and
    the function is not implemented, feel free to request it – we are happy to
    consider implementing it for a future version of LabVIEW.  If you are using the MATLAB Script Node, I
    suspect the problem is with the way the node is setup, or with the ActiveX
    server.
    Again, thanks for posting-
    Message Edited by Travis M. on 07-18-2006 10:37 AM
    Travis M
    LabVIEW R&D
    National Instruments
    Attachments:
    untitled.JPG ‏62 KB

  • Insert of Matlab script

    Hi all, I am new to Labview and need some help in doing my project. I know that Matlab script can be written in Labview and would like to know the procedures. Does anyone has any examples or tutorial on this? Thanks in advance
    Rgds,
    Tay

    Hi Tay,
    If you want to include MATLAB script directly in your VIs, you will need to use the MATLAB Script Node, found in the Mathematics > Scripts and Formulas > Script Nodes palette in LabVIEW 8.0.  There are also some MATLAB Script Node examples in your LabVIEW directory...specifically, the examples\scriptnode folder.  And of course, if you search the LabVIEW Help for "MATLAB Script Node" you should find some helpful documentation on the subject.
    Also, if you're using LabVIEW 8.0, you should try out the MathScript Node, which is similar to the MATLAB Script Node, except with MathScript, all of the work is being done in LabVIEW...MATLAB is not required.
    Good luck,
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • How to load a variable using MATLAB Script?

    I need to load a selected variable from .mat file, using MATLAB script , and analyse it.
    the attched shows my vi, there are two inputs nodes 'file' contains the .mat file path, and 'varn' contains varibale name in that .mat file which can be selected by user. Using " load(file)" the whole .mat file is loaded in the workspace and become avaiable at output node, however I am not able to pass a selected variable name through string "varn" input, MATLAB script does not recognize the variable.
    any idea to reslove it is realy appreciated.
    Attachments:
    load a variable.JPG ‏18 KB

    Download the VI and .MAT file. Run the VI, and it'll plot the data inside of the .MAT file.
    Andy Chang
    National Instruments
    LabVIEW Control Design and Simulation
    Attachments:
    testfile.zip ‏5 KB

Maybe you are looking for