Matlab script launched from labview

Hi everyone,
I need to run a matlab script controlling a network analizer from labview. I use labview to start the movement of the motors in some experiment. Then, once the movement starts, matlab should run a script to perform adquisition and treatment of the data. Could anyone give me some trick of how to launch the matlab script?
Best

Here is a link that looks to describe what you are asking
http://zone.ni.com/reference/en-XX/help/371361J-01/lvhowto/creating_a_matlab_script/
Hope that helps.

Similar Messages

  • Calling matlab 6.0 from labview

    I need know how to start Matlab 6.0 from Labview, and I will need to pass strings of script commands (for example, a=10;b=5;c=b/a;disp(c)) to Matlab to be executed. And Labview will need to get the result (value of c) back. Thanks for all the help!

    You can use the matlab script funtion under Functions»Mathematics»Formula»MATLAB Script
    Also you can find the matlab script examples in the examples»communication»Importing MATLAB Script.
    I hope this helps... Have fun
    Ogulcan

  • Closing a Matlab model window from Labview

    Hi,
    I use Labview with the Simulation Interface Toolkit to control a simulation system from Labview. I need to change the Simulink model dynamically from Labview when the users choose a given option (I directly replace code snippets in the .mdl file). In order to do this, I need to close the model window in Matlab from Labview and reload it when the modification is done.
    Any idea?
    Thanks,
    Alex

    Greetings!
       Thanks for the request. Re-launching the model is required after
    every change. The connection manager retains the information and uses it in re-launch.
    Please refer to Page 16 of the simulation interface toolkit. You can submit a
    product suggestion in our product suggestion page. Also I am sure you would
    know the following -
    You could build the model into a DLL for stand-alone simulation. You need
    MATLAB, Simulink, and Real-Time Workshop to build a model DLL and configure the
    user interface using the SIT Connection Manager Dialog box. Once you create the
    model DLL and user interface, you need only LabVIEW to run the simulation.
    Thanks and hope this helps. Good luck
    Avi

  • I can't find the MATLAB script node in labview

    We are using a MAC G4 with OS 9. We also have labview 5.1. I have looked under Mathematic>>Fomula in the tools palette and I cannot find the MATLAB script node.
    Is there an extra download that I need to get this MATLAB script node?

    The HIQ and MATLAB script nodes are only available in the full and professional development systems. If you have one of these versions, these nodes should be under the Mathematics>>Formula palette.
    If you have the base package of LabVIEW, you will not have access to these script nodes. Details about which options are included in which development packages can be found at:
    http://www.ni.com/labview/devchart.htm

  • Calling Matlab 7.1 from LabView 6.1

    Hello,
    I am using LabView 6.1 and I have recently installed Matlab 7.1 on the same machine.
    When I try to call Matlab by a Matlab script node, I only get the error
    message that the script could not be executed and that a failure
    occured calling the script server. (This does not depend on what script
    I implement.)
    Earlier, I had Matlab 6.5 which worked well with the script nodes.
    What can I do to get the script nodes running?

    Hello ffffff 
    I can pretty much assure you that LabVIEW 6.1 has not been tested with MATLAB 7.1, and "officially" I might go so far as to say it's not supported.
    That said, you might try downloading the MATLAB Script.zip file attached to this KnowledgeBase entry:
    http://digital.ni.com/public.nsf/allkb/4475BC3CEB062C9586256D750058F14B
    Follow the directions in the KB to update the matscript.dll file in your LabVIEW 6.1 distribution, and this might resolve the issue.  This addressed numerous issues with the MATLAB script node so that version 7.0 of MATLAB would work well with LabVIEW.  I'm not sure if this version of the matscript.dll has been tested with LabVIEW 6.1 or not, but in theory it should work.  Also, if the problems you are encountering are new to MATLAB 7.1 in specific, there may not yet be a solution for this; I don't know how new MATLAB 7.1 is.
    Good luck!
    Message Edited by Jeff B on 02-16-2006 07:44 AM

  • ActiveX can't create object when VB Script called from Labview

    I have an interesting issue that I can't find a solution for. I am using the DIAdem Run Script.VI in Labview to call a script that opens an Outlook object and sends an email. When the script is called via LabView I get this error:
    However, when I manually run the script from the DIAdem script tab it works as expected with no errors.
    This is the code:
    'Begin email send function
    Dim oOutlookApp
    Dim oOutlookMail
    Dim cnByValue : cnByValue = 1
    Dim cnMailItem : cnMailItem = 0
    ' Get Outlook Application Object
    Set oOutlookApp = CreateObject("Outlook.Application")
    ' Create Mail Item
    Set oOutlookMail = oOutlookApp.CreateItem(cnMailItem)
    ' Set Mail Values
    With oOutlookMail
    .To = "[email protected]"
    .Subject = "Report: " & Data.Root.ActiveChannelGroup.Name & " for " & CurrDate
    .Body = "test automatic report emailing with VB Script."
    ' Add Attachement
    Call .Attachments.Add(strLocFileName, cnByValue, 1 )
    ' Send Mail
    Call .Send()
    End With
     (Original code includes Option Explicit and all variables are properly included/declared, I just took the snippet of what's causing the error).
    I have looked at the following threads for info already:
    http://forums.ni.com/t5/DIAdem/Some-errors-when-calling-LabVIEW-VIs-Interactively-from-DIAdem/td-p/2...
    http://forums.ni.com/t5/DIAdem/Active-X-component-cannot-create-object-Diadem-8-1/m-p/71212/highligh...
    -I tried running the script via Windows explorer (per Brad's suggestion) by itself without the DIAdem specific functions and it runs fine.
    http://forums.ni.com/t5/DIAdem/Error-while-runing-diadem-asynchronous-script-from-labview-on/m-p/111...
    -I am not running the scripts asynchronously
    Using Windows 7 (64bit), DIAdem 11.2 and LabView 7.1.1
    Thank you.

    Hey techerdone -
    I'm afraid I personally can't be of much help - I tested your code both from DIAdem and from LabVIEW and each worked without issues in both cases (Outlook closed, Outlook open).  I'm using DIAdem 2011 SP1, LabVIEW 2011, and Outlook 2007...
    Derrick S.
    Product Manager
    NI DIAdem
    National Instruments

  • I need to get error from sql script launched from class

    Hello.
    I need to run a bat file (windows xp) inside a PL/SQL procedure and I must check the codes returned by the command.
    I am trying with these files:
    comando.bat
    sqlplus -s fernando/sayaka@ferbd %1
    exit /Bkk.sql
    whenever sqlerror exit sql.sqlcode rollback
    declare
      v_res number;
    begin
      select 1
           into v_res
           from dual
       where 1=2;
    end;
    exit sql.sqlcodeEjecutarProcesoSOreturn.java
    import java.lang.Runtime; 
    import java.lang.Process; 
    import java.io.IOException; 
    import java.lang.InterruptedException;   
    public class EjecutarProcesoSOreturn
        public static int ejecuta(java.lang.String  arg0, java.lang.String arg1)
            java.lang.String[] args= new String[2];
            args[0]=arg0;
            args[1]=arg1;
            int ret = 0;
            System.out.println("En ejecuta");           
            try
                /* Se ejecta el comando utilizando el objeto Runtime
                y Process */               
                Process p = Runtime.getRuntime().exec(args);      
                try
                    /* Esperamos la finalizacion del proceso */                 
                    ret = p.waitFor(); 
                    //ret = p.exitValue();                
                catch (InterruptedException intexc)
                    System.out.println("Se ha interrumpido el waitFor: " +  intexc.getMessage());
                    ret = -1;            
                System.out.println("Codigo de retorno: "+ ret);    
            catch (IOException e)
               System.out.println("IO Exception de exec : " +               e.getMessage());              
               e.printStackTrace();          
               ret = -1;            
            finally
               return ret;
        public static void main(java.lang.String[] args)
            System.out.println("En main");  
            System.out.println("args[0] " + args[0]);           
            System.out.println("args[1] " + args[1]);   
            ejecuta(args[0], args[1]);
    }  When I launch the script from a console I get:
    D:\Ejercicios_Oracle\BATCH_SCRIPTS>comando.bat @kk.sql
    D:\Ejercicios_Oracle\BATCH_SCRIPTS>sqlplus -s fernando/sayaka@ferbd @kk.sql
    declare
    ERROR en lÝnea 1:
    ORA-01403: no se han encontrado datos
    ORA-06512: en lÝnea 4
    D:\Ejercicios_Oracle\BATCH_SCRIPTS>exit /BAnd if I check the errorlevel I get:
    D:\Ejercicios_Oracle\BATCH_SCRIPTS>echo %errorlevel%
    1403When I run it the class I get:
    D:\Ejercicios_Oracle\BATCH_SCRIPTS>java EjecutarProcesoSOreturn comando.bat @kk.sql
    En main
    args[0] comando.bat
    args[1] @kk.sql
    En ejecuta
    Codigo de retorno: 0And if I check the errorlevel I get:
    D:\Ejercicios_Oracle\BATCH_SCRIPTS>echo %errorlevel%
    0How can I get the code 1403 returned from the class?
    Thanks in advance.

    I am trying to extract the error code from the Process.getInputStream() but it seems as if I do not have some privileges.
    This is my class right now:
    import java.lang.Runtime; 
    import java.lang.Process; 
    import java.io.IOException; 
    import java.lang.InterruptedException;   
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.InputStream;
    public class EjecutarProcesoSOreturn
        public static int ejecuta(java.lang.String  arg0, java.lang.String arg1)
            java.lang.String[] args= new String[2];
            args[0]=arg0;
            args[1]=arg1;
    int ret = -100;
            //System.out.println("En ejecuta");           
            try
                /* Se ejecuta el comando utilizando el objeto Runtime y Process */     
                Process p = Runtime.getRuntime().exec(args);      
    ret = -101;   
                try
                    /* Esperamos la finalizacion del proceso */                 
                    ret = p.waitFor(); 
                    //ret = p.exitValue();
                    InputStream bis = p.getInputStream();
                    InputStreamReader isr = new InputStreamReader(bis);
                    BufferedReader br = new BufferedReader(isr);
                    String line = null;
                    String msg = null;
                    String errCode = null;
                    boolean oraError = false;
    ret = -102;   
                    while ( (line = br.readLine()) != null)   
                      //System.out.println(line);
                      if ((line.length() >= 5) & (!oraError))
                        msg = line.substring(0,4); 
                        if (msg.equals("ORA-"))
                             oraError = true;
                             errCode = line.substring(4,9);
    ret = -103;   
                          //System.out.println(errCode);
                          ret = Integer.parseInt(errCode);;
                catch (InterruptedException intexc)
                    //System.out.println("Se ha interrumpido el waitFor: " +  intexc.getMessage());
                    ret = -1;            
            catch (IOException e)
               //System.out.println("IO Exception de exec : " +               e.getMessage());              
               //e.printStackTrace();          
               ret = -1;            
            catch (Exception e)
               //System.out.println("IO Exception de exec : " +               e.getMessage());              
               //e.printStackTrace();          
               ret = -104;            
            finally
               //ret = -100;   
               System.out.println("Codigo de retorno: "+ ret);
               return ret;
        public static void main(java.lang.String[] args)
            System.out.println("En main");  
            System.out.println("args[0] " + args[0]);           
            System.out.println("args[1] " + args[1]);   
            ejecuta(args[0], args[1]);
    }  And when I call the main method with these parameters then I get:
    D:\Ejercicios_Oracle\BATCH_SCRIPTS>java EjecutarProcesoSOreturn d:\comando.bat @d:\kk.sql
    En main
    args[0] d:\comando.bat
    args[1] @d:\kk.sql
    Codigo de retorno: 1403I have this pl/sql function:
    CREATE OR REPLACE FUNCTION FERNANDO.EjecutarProcesoSOreturn (param1 VARCHAR2, param2 VARCHAR2) return NUMBER
    AS LANGUAGE JAVA  name 'EjecutarProcesoSOreturn.ejecuta(java.lang.String, java.lang.String) return java.lang.int';I have granted some privileges to the user FERNANDO:
    begin
        dbms_java.grant_permission
        ('FERNANDO',
         'java.io.FilePermission',
         'd:\comando.bat',
         'execute');
        dbms_java.grant_permission
        ('FERNANDO',
         'java.lang.RuntimePermission',
         'writeFileDescriptor' );
        dbms_java.grant_permission
        ('FERNANDO',
         'java.lang.RuntimePermission',
         'readFileDescriptor' );
        dbms_java.grant_permission
        ('FERNANDO',                   
         'java.io.FilePermission',    
         'd:\*',               
         'read,write');
    end;
    /and when I try the function, I get:
    SQL> DECLARE
      2    RetVal NUMBER := 0;
      3    PARAM1 VARCHAR2(200);
      4    PARAM2 VARCHAR2(200);
      5 
      6  BEGIN
      7    PARAM1 := 'd:\comando.bat';
      8    PARAM2 := '@d:\kk.sql';
      9 
    10    RetVal := EJECUTARPROCESOSORETURN ( PARAM1, PARAM2 );
    11    dbms_output.put_line('RetVal: '||RetVal);
    12    --ROLLBACK;
    13  END;
    14  /
    RetVal: -102Could you please tell me what my problem is?

  • Matlab script window in labview 7.0

    In labview 7.0 the matlab window associated with the scripts server is normally hidden and not accessible to the user. In LV 6.x it was and provided a flexible and interactive way of collecting, analyzing and storing data as matlab workspace.
    Is there an alternative way to access the script server and its workspace under LV 7 ?

    The script server window is not hidden on my machine and I am using LV 7 with Matlab R12. I am not sure how to change this setting (or even if it's possible).

  • I have some software problems of running matlab script node in the LabVIEW program.

    Hi there,
    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=Mat​hScript&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.  

    This board is for Mathscript, but you seem to have a matlab problem. You should probably post in the LabVIEW forum instead.
    What is your LabVIEW version? What is you matlab version?
    LabVIEW Champion . Do more with less code and in less time .

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

  • Matlab script sever don't work in labview

    in my application ,matlab script always doesn't work with a error1050,even the matlab script examples in labview help examples also can't work at all, can you
    tell me the reason.

    Marc,
    You have one forgotten possibility to communicate LabView with remote
    MATLAB - it is TCP/IP.
    It is easy to realize and may be helpful in your application.
    Regards,
    Sergey.
    "Marc" wrote in message
    news:[email protected]..
    > Hi Sergey
    >
    > Yep the files look interesting - as well as the control. The actual
    > application is to make sure we have realtime data exchange along with
    > 'callback' functionality. There are a variety of approaches - reading
    > mat files, using DDE and COM. NetworkDDE is not supported by matlab -
    > so that is one option gone. Using shared network drives is a solution
    > - but still means Matlab and Labview are mutually dependant. With DC
    OM
    > (and Matlab in /Automation mode) it is possible to have two 'masters'
    > talking independantly without shared network drives...
    > I think at the end I will have to construct a new control (or cin)
    > module to do this...
    > Marc

  • Error 1050, when calling MATLAB 7.1 from LV8.0 - Function Definitions not allowed.

    I am trying to call a MATLAB M-file from LabVIEW 8.0. I keep getting Error Code 1050:
    "Error 1050 occurred at LabVIEW:  Error occurred while executing script. Error message from server: ??? Error: Function definitions are not permitted at the prompt or in scripts.
    . in rickfito.vi->impedo.vi
    Possible reason(s):
    LabVIEW:  Error occurred while executing script"
    I tried running the sample MATLAB script example on the knowledge base, and everything works fine.
    I am guessing that this error is happening because I have functions defined in the MATLAB script. But i thought this is better programming techinque. Also, the MATLAB window opens up when I start the VI.
    Is there a way around this? I really do not want to remove the function definitions on the script.
    Thx,
    Pelo...

    First, see if the Matlab Script Node is trying to open any files. If
    so, then make sure that the current Matlab directory is set to the
    directory where that file is located. The Matlab script node in LabVIEW
    does call the Matlab script server and executes the function in the
    Matlab script node through Matlab. Therefore, even though LabVIEW may
    be in the correct directory where the file is located, make sure Matlab
    is as well.
    The error may also occur if there is a disruption
    in the script server between MATLAB and LabVIEW and the connection was
    never re-established (possibly by closing MATLAB prematurely). Close
    both LabVIEW and MATLAB then relaunch them both and run the VI.
    MATLAB®
    is a registered trademark of The MathWorks, Inc. Other product and
    company names listed are trademarks and trade names of their respective
    companies.
    -Bob
    -Bob

  • Using matlab script

    Hello!
    I'm using matlab script block in my aplication. The m-file (from matlab) contain an 'if' that depends of an input of labview.
    I want to pass trough this condition only once when input's value changes, but labview "covert" this 'if' in a 'while' and pass trough this sequence n times.
    How can I to impose to pass throug the sequence once the input's value change. It's better to specifie it from matab or from labview.
    Thank you in adavance 

    What is surrounding the matlab script block? LabVIEW should be modifying the matlab code, it should be connecting with matlab and matlab executes its code, returning the results to LabVIEW. Can you do a screen capture of the part of the code that contains the matlab stuff? If yes make sure that it is saved as a .jpg (not .bmp!) for size reasons. If not, if you can send the part of your code that includes the matlab stuff that would help.
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

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

Maybe you are looking for

  • Looking for simple timeline/calendar screenlet/widget.

    Good day gentlemen, I'm looking for a simple screenlet or widget for linux that is a calendar, but designed to be more of a timeline of past events than a reminder of future events. For my specific purpose in this case I'm trying to lose weight. So I

  • Ipod touch, Freezing while syncing.

    everytime i connect my ipod it syncs my music and pictures fine, but when it starts to sync my apps it syncs about 3 apps. Then my ipod freezes while syncing, forcing me to restore my ipod from recovery mode. When i say it freezes, i mean that my ipo

  • EP 70 connectivity with ECC 6.0 (SAP NW2004s)

    Hi, I have recently upgrade r3 4.7 (32 bit) to ecc 60 (64bit) We also install EP 70 (NW2004s SR3) I am not able to connect Enerprise Portal 70 to ECC 60 system Also how to put ESS business package in EP regards vikas nagar

  • Can't edit greyed-out HTML [was: hi]

    can anyone help us out we editing html file on dreamweaver, but some file can not be edited due to be grey or locked ... not to unlock it please help really appreciated [Subject line amended by moderator for clarity]

  • Error when calling BPEL process from web service client

    I have created three projects here ,there're no problem when testing Composite Application(SynchronousSampleApplication) by test case inside this project. When I create a Java Application(SynchronousSampleApp),inside this project I've created a web s