Dynamically loading the MathScript Node

Hi - Is it possible to dynamically load script into the Mathscript Node at Run time. I see that you can use define functions and paths and things . But being a newbie to Mathscript could all this hang together to make dynamic loading a possibility and how?
thanks dht 

Hi,
  unfortunately the node doesn't support run-time dynamic loading of scripts. You can load variable values with the load function, but not scripts.
http://zone.ni.com/reference/en-XX/help/371361A-01/lvtextmath/msfunc_load/
http://zone.ni.com/reference/en-XX/help/371361A-01/lvhowto/saving_loading_scripts/
Depending on your application, you could use a case statement to decide between several pre-built (and possibly compiled) mathscript nodes, and acheive the functionality that way.
Another option might be to use the formula vi's instead, although this will require a more complex architecture to parse the text file you'd generate.
For more information on MathScript, please see the following link
http://zone.ni.com/devzone/devzoneweb.nsf/Opendoc?openagent&568C773718B080F286257096005BD314
Hope that helps
Sacha Emery
National Instruments (UK)
// it takes almost no time to rate an answer

Similar Messages

  • Changing a path dynamically in a MathScript node

    I have inherited a MatLab script that must be run in LabView. The first issue I have is creating unique paths. When a Unit Under Test runs, its data will be saved to a file based on the serial number of the UUT. The MatLab script then analyzes the data from that file and creates a new file based on the serial number with a new file extension. Therefore, I need to read in a file whose path changes and write a file whose path changes. The relative path will be the same but the unique file will not. I am looking for suggestions on how to do this since there will be hundreds of serial numbers being tested. It would be nice if the node could have an input that could configure to a path or string type instead of a scalar only. The serial numbers will be apha-numeric and this must be able to exist as a stand alone application.
    Also, the node reports a 'unexpected token: function'. I am noticing that functions must be a seperate .m file but how do you call the function after that?
    I am using LV 8.5
    Thanks - Jeff
    Message Edited by j.masse on 07-07-2008 07:57 AM

    Hello Jeff,
    Creating unique paths is not difficult in MathScript.  Simply pass in the string you want to use as the specific part of the path and have a local variable contain the base path.  For example, if you have a string input named serial to the MathScript node, the following code will build a path:
    basepath = 'c:\data\';
    filename = [basepath serial];
    You mention needing to do this for a large number of files.  The easiest way to do this is to have your loop in LabVIEW and simply pass in one string at a time to the MathScript node to do your processing.  If there is a lot of setup work involved before the work that needs to be done for each file, then it is more complicated.  There really isn't a concept of an array of strings in the language.  The closest you can get is a cell array containing many 1D character arrays.  However, LabVIEW MathScript does not yet support this construct.
    You can pass in a LabVIEW 1D string array -- the MathScript node input will adapt to the type wired to it.  What it does is create a 2D character array in MathScript.  If not all the strings are the same length, then it will pad the end of the string with zeros.  This presents a problem when you try to use the string as a filename.  However, you can use the strrep (string replace) function to replace the zeros with empty strings.  For example, assuming you have an input variable named serial that is a 1D array of strings and a loop-control variable named index, type
    basepath = 'c:\data\';
    name = strrep(serial(index, : ), char(0), '');
    filename = [basepath name];
    You cannot write a function inside of a MathScript node.  What you can do is create a .m file on disk and add the directory to your MathScript search path.  The default search path is your "My Documents\LabVIEW Data" directory.  But if you add the file elsewhere, there are three ways to set the search path for MathScript.  First, from the MathScript Window, go to "File >> LabVIEW MathScript Properties" and click on the "MathScript: Search Paths" category item.  This will set the search path for the MathScript Window only.  Second, from a LabVIEW VI, go to Tools >> Options and click on the "MathScript: Search Paths" category item.  This will set the search path for all VIs in the main application instance only.  Third, from within the project explorer, right-click on "My Computer" and select Properties.  Then click on the "MathScript: Search Paths" category item.  This will set the search path for that context only.  Since you are talking about using this in a built application, the third option will likely be what you need.
    As for using a built application generally, as long as you avoid any MathScript function that describes itself as being unsupported in the run-time engine, you should be okay.  The help for individual functions will list if they are unsupported.  You can see a list of all such functions by looking in the LabVIEW help index for "MathScript" and double-clicking on the entry for "functions not supported in Run-Time Engine."
    Grant M.
    Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments

  • Are you using the MathScript Node in LabVIEW or the MathScript Interactive Window?

    Are you using the MathScript Node in LabVIEW or the MathScript Interactive Window? I am very excited with the MathScript Node inside LabVIEW. However, I would like to see what other people think.
    Avalim

    Avalim,
    Personally, I am determining that I like to use the MathScript Node in LabVIEW.  It makes it easier for me to pass my data in and out of the LabVIEW environment!!  But, like you, I am excited to see what any other users think!!
    -Jeff P
    Jeffrey P.
    LabVIEW Product Management
    National Instruments

  • Is it possible to define a function in the MathScript Node

    Is it possible to define a function in the MathScript Node

    You can not define a function inside of a MathScript Node, but only because it isn't necessary. The way custom functions work in MathScript is that they are saved in .m files located in paths in the MathScript path list. When the MathScript compiler receives a function that it doesn't recognize, then it searches for it in the path list, and upon finding it, compiles and loads the function. You can specify these search paths manually by going to File>>MathScript Preferences from the MathScript Window or dynamically by using the path() command within a script.
    To answer your original question, if you would like to create custom functions dynamically within a VI, then you can simply build your custom functions using strings and then save them to an ASCII file with the extension .m. You could either save the file to a path already in the MathScript path list or you could dynamically specify the path by passing the path into a MathScript Node as a string and by using the path() command at the beginning of your script to set it.
    Kind Regards,
    E. Sulzer
    Applications Engineer
    National Instruments

  • Problem with dynamically loading the dropdown list from database

    Please help me,
    i am having a jsp page which contains a form
    with a textfield ,two dropdown list
    and a submit button
    when i select a list from first drop down, second drop down has to
    be loaded from the database dynamically according to the
    selected one in the first drop down.
    i gave onselect event for the first drop down and
    gave this one
    temp=first dropdown selected value
    self.location='currentfile+query='+temp;
    after this current page is reloading, but the already existing
    values in textfield and first selected value in drop down list is
    missing.
    how to solve this problem? and the rest of the problem. i mean
    loading the data into second drop down list.
    plz help me......

    in first <selcet> tag write Onchange and submit to the jsp then the values will return in second select box.

  • Dynamically loading the url of a web reference object in C#

    Hi,
    We have a number of assemblies (C# - VS 2010) that access third party web services via SOAP.  The url to access the site is part of the web reference object.
    We have need to be able to change the url used to access the service at run runtime when conditions require.
    What would the be the best practice of dynamically setting the url to be used at run time?
    Thanks in advance.
    SanDegan99

    You could specify the URLs as keys in the application configuration file (App.config or web.config) of the main application:
    https://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/aa374182(v=vs.85).aspx
    App.config:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <appSettings>
    <add key="url1" value="http://www.url.com/test.asmx"/>
    </appSettings>
    </configuration>
    You can then retrieve these values using the ConfigurationManager class in any assembly that is referenced from the main application like this (add a reference to System.Configuration.dll):
    string url = System.Configuration.ConfigurationManager.AppSettings["url1"].ToString();
    You can change the values of the keys in the application configuration file without having to recompile the application.
    The other option is to specify the URLs in a database or some other persistent storage from which you read at runtime but configuration files are generally used to store these kind of variable application settings.
    Please remember to mark helpful posts as answer to close your threads and remember that any new question you may have should be asked in a new thread of its own.

  • Dynamically load the Version info from maven

    Hello,
    I am working on a project which is managed by maven.
    I want to load the version info marked in project.xml(conf file for maven) from my swing app.
    One way is to generate a class holding a static attribute indicating Version using maven.
    Anyone has some other suggestions?
    Thanks in advance

    Hello,
    I am working on a project which is managed by maven.
    I want to load the version info marked in project.xml(conf file for maven) from my swing app.
    One way is to generate a class holding a static attribute indicating Version using maven.
    Anyone has some other suggestions?
    Thanks in advance

  • Dynamically rename the root node of XML based on the child elements

    Hi Gurus,
    Is there any way to rename the root node of the resultant XML after a mapping based on the child elements.
    For ex:
    consider the following resultant XML after mapping
    <result>
    <element1> </element1>
    <result>
    if the element1 is <type> then the output should be
    <category>
    <type> </type>
    </category>
    elseif the element1 is <character> then the output should be
    <property>
    <character> </character>
    </property>
    Let me know how to do this, either in XSLT or in Graphical mapping.
    Thanks,
    Prabu

    Hi, Prabu:
    In this case, I am suggest you have Src and Tar Message.
    I am suggesting you create another type of message using key / value pair as I suggested, e.g. called Mid Message.
    My solution for you is to have two message mappings:
    1. Src -> Mid
    2. Mid -> Tar.
    In first mapping, you have no control of the structure, but you can map it to Mid structure:
    e.g.
      if Type node Exist, then map 'Type' to Key, as Key/Value can be creatd under a parent node with 0:1 Occurrence.
      saying item.
       in this case, a new item created.
    If you think of this way, any xml file can be represted in this way:
       <Employee>
          <Fname>David</Fname>
          <Lname>Miller</Lname>
       </Employee>  
       <Employee>
          <Fname>Steve</Fname>
          <Lname>Mai</Lname>
       </Employee>   
    Can be interpretd as this way:
       <Employee>
          <Element>
             <key>Fname</Key>
             <value>David</Value>
          </Element>
          <Element>
             <key>Lname</Key>
             <value>Miller</Value>
          </Element>
       </Employee>  
       <Employee>
          <Element>
             <key>Fname</Key>
             <value>Steve</Value>
          </Element>
          <Element>
             <key>Lname</Key>
             <value>Mai</Value>
          </Element>
       </Employee> 
    Now you should understand what I mean.
    In your case target structure have to desgined as following way:
    You need to put Category and Property together with their sub-structure in parallel, make occurence to 0:1
    In your second mapping, you can check the key value is "Type" or "Character", based on which one is true,
    you create corresponding structure: either Categary or Property.
    Regards
    Liang
    Edited by: Liang Ji on Oct 22, 2010 8:31 PM
    Edited by: Liang Ji on Oct 22, 2010 8:35 PM

  • Dynamically load the content without re-starting the server

    Let me explain the scenario.........
    I have a JSP in which I call a method written in a different class( java file).
    Now, when I change the content of the method in the class and compile it, how can I get the updated stuff in the JSP without re-starting the server.
    Even though I have to re-deploy the changed class, I need to re-start the server to get the updates effective.
    The env set up is on Tomcat
    fun_one

    FUN_ONE, I am using Tomcat 5.0 (though not 5.5), and have a Test application that I do not use WARs to deply. The Context is set with reloadable="true".
    I have this simple bean:
    package jsp.beans;
    public class ItemBean implements java.io.Serializable
         public String getjunk() { return "Hello"; }
    } And this JSP
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <html>
      <head>
      </head>
      <body>
        <!-- Display the session ID for this user -->
        <p><c:out value="${pageContext.session.id}"/></p>
        <!-- Get the junk string from the ItemBean -->
        <p><jsp:useBean id="it" class="jsp.beans.ItemBean"/>
        <c:out value="${it.junk}"/></p>
      </body>
    </html> I run the JSP, then change the text returned by the bean, recompile it, then reload the JSP (force reload). The session id remains the same, and the text changes. Does this work on your system? (note, you do have to restart your server once after you set the Context to be reloadable="true")

  • Mathscript node problem - specgram function of matlab

    Hello...
    I used to use "specgram" function
    of matlab, in a M file builded to perform FFT spectral analysis in
    signals. I am trying to build a VI to perform the same action.
    In
    a blank VI I created a Mathscript node and pasted the code of my M file
    inside it. After adjust the input and outputs of the node, I run the VI
    and received the Error message "Unknown symbol on line 7 : specgram"
    How do I solve this issue? How do I execute the specgram inside the mathscript node?
    Thank you in advance
    Dan07

    Hello Luciano...
    -    First of all I use the “load” command to open an ASCII file into Matlab;
    -    The ASCII file has 3 columns:
    o    Column 1: Time Series
    o    Column 2: 900 seconds of Signal 1
    o    Column 3: 900 seconds of Signal 2
     “After this point, all the operations were performed in the same way
    to both signals, I will in the next steps talk about only one signal to
    produce  a short text
    -    The Signal was interpolated by cubic spline interpolation using 10 Hz (one point each 100 ms);
    -    The new sequence of values of the signal has 9001 values;
    -    This new series was splitted into 34 segments of 512 points each, overlapped by 50 % (256 points);
    -    Short Time Fourier Transformation was performed in each segment, using the specgram function of Matlab;
     This operation resulted in 5 ascii files:
    o   B: ascii file with 34 columns, each
    column represent one segment and has the values that build the spectrum
    of the segment - signal 1
    o   C: ascii file with 34 columns, each column represent
    one segment and has the values that build the spectrum of the segment -
    signal 2
    o   pi: ascii file with one column with 9001 interpolated values - signal 1
    o   fi: ascii file with one column with 9001 interpolated values - signal 2
    o   X: ascii file with 4 columns and 34 lines (one line for each segment), with mean and SD values for signals 1 and 2
    I have already build a VI that generates the interpolated series of values and splits it as well, but using spectrogram function in labview I didn't get the same results (values) of specgram (matlab).
    Thanks in advance
    Dan07
    Attachments:
    Code.vi ‏16 KB

  • How to use FMINUNC in the MathScript - LabView 8?

    Inside the Mathscript node I have the following script:
    [xmin, fval] = fminunc('test',[2;2])
    and the function test is defined in the file test.m that has the following content:
    function f = test(x)
    f = x(1)^2 + 2*x(2) - 1
    The problem is that the FMINUNC is returning nothing to xmin neither to fval.
    Is it a bug or there is a problem with my code?
    I tried the sample given in the help and the problem is the same.

    Hi,
    ........... I use JDev 11g ..............
    If you make your inputText disabled -----> shortDesc will not be displayed.
    You can make a workaround to achieve this by using popup as :
    1- add showPopupBehavior inside your inputText as :
    <af:inputText label="label1" id="it1" disabled="true">
                    <af:showPopupBehavior triggerType="mouseOver"
                                          align="endBefore" alignId="it1"
                                          popupId="p1"/>
                  </af:inputText>2- add a popup which will display your shortDesc text
    <af:popup id="p1">
                      <af:outputText value="Sameh POPUP" id="ot1"/>
              </af:popup>I hope it is useful.
    Sameh Nassar

  • Calling a .m file from inside a mathscript node

    hello all i am hoping someone can help me out, I am in the process of converting our version 7.11 matlab node vi's to mathscript (I hope) AND I HAVE RUN INTO AN ISSUE. we have a very simple matlab script that bundled the data and sent it to another matlab sub routine. when i copy this script over to mathscript I get the following eror: Unknown symbol on line 13: Pre_Process_Function_Pulse. Is there a way I can call and run these subroutines from the mathscript node? Do i need to convert the sub routines into a mathscript file? or do i just need to change the syntax for my call? bmp of the offending line in mathscript attached. please forgive if this is an easy question, I am not really a matlab programmer, the files that we are running are provided from elsewhere, and i get to integrate them any and all help is always appreciated thanks Chris
    Attachments:
    mathscript.JPG ‏51 KB

    Hello again,
    Ok I am still having issues running the matlab script in mathscript.  I have gone back to the original scripts with all the nested sup routines.  and the mathscript code is just a call to the first .m file subroutine.  but for some reason mathscript will not recognize the function call as a call?  I recreated the original matlab node in a sequence, so the matlab node runs (successfully) and then the next sequence is the identical call in mathscript.  I have set the path in mathscript to the directory where all the .m files are located.  The pre-process_function_pulse .m file sequentially calls 6 very small .m subroutine files.  all are located in the same directory.  and this directory is the only one listed under path and working directory in Mathscript preferences.  Additionally from the last suggestions all traces of the original japanese comments have been deleted from all the .m files.  The inputs and outputs are the same for the matlab and mathscript nodes.  so i am basically at a loss here.
    Any and all help will be greatly appreciated.
    thank you
    Chris
    Attachments:
    mathscript.doc ‏138 KB

  • How to Dinamicaly load-save JTree nodes ?

    Hi !
    A have one program. Use 1 JTree with a lot of nodes. (200.000-1.000.000. is much)
    For every node store is sored 7-8 boolan variables, 2long, and 5-6 String variables, whitch legth is 3-20. (Not much).(Information about files avaible somevhere)
    Now I save the root node(or the treeModel ) with ObjectOutputStream and load with ObjectinputStream. It generates 10-45Mb. I can export to XML but need about 350Mb memory to construct the DOM.an dthe Savad xml is 90Mb. It take long time to load, take a lot of memory.
    But don`t need to be stored all in the sytem memory. It is enugth to be stored one node, and after the user select that node load information about chilld nodes from the stored file and construct the child nodes, if the child node is selected(or try to be expanded) load information from file again.
    I think it is an idea to store somehow key-values but with PropertiesResourceBundle it is slow again. How is posible to store my data?
    Can you help me to store data dinamicaly in file and read from that?.

    How is posible to store my data?This is the real question, isn't it? Not how to load and save them, that comes later.
    You give each node an arbitrary identifier. A number works well. Then create a database table where you store the node identifier, the node's parent identifier, and the various information that belongs to the node. (If the node is the root node, store NULL as its parent).
    Then, to load the root node, find the database row whose "parent" column is NULL. Read that, make a node out if it, and set it as the root of your tree. To load the children of a node (you'd do this in a TreeWillExpandListener if I remember the name correctly) you find the database rows whose "parent" column is the node that is expanding. Read them, make nodes out of them, and add them as children to that node.
    There's more to it than that, of course, but that should be a start, I hope.

  • How to feed a cluster into the mathscript?

    Hi all,
      I am trying to feed a cluster into the mathscript. I found that if the name of the cluster element does not have any space or special characters, it works pretty well. But it doesn't run if the name of the cluster elements have any special characters. Is it how Mathscript designed? Any workaround here?
    Solved!
    Go to Solution.

    Hey dragondiver,
    Hope you're doing well today. This document overviews the intended use and behavior of data types with MathScript.
    Passing Data in and out of the MathScript Node (MathScript RT Module)
    http://zone.ni.com/reference/en-XX/help/373123C-01/lvtextmathmain/ms_passing_data_lv_mathscript/
    So, to answer your question more specifically, the rule for naming of elements within a cluster passed into the Node is,
    "You must label individual elements of the cluster. Labels must start with an alphabetic character and can contain only alphanumeric characters and underscores without any spaces."
    This should account for the behavior you're seeing with your code!
    Tim A.
    National Instruments

  • How to make a text based language in mathscript node executed faster?

    Hello Everyone,
    I have build a VI contains mathscript function node, due to the big data needs to run it takes long time to finish the execution, is there any way to make the process faster, such as building shared library so it can be called by call library function node, or this only valid for c and c++ .
      any help will be highly appreciated

    smercurio_fc wrote:
    There is no way to convert the Mathscript code to a shared library.
    Please post what you're actually doing in the Mathscript node. As Gerd noted, there's probably a way to do this using native LabVIEW functions.
    While it may not be possible for a direct conversion from MathScript code to a DLL, it is possible to build a shared library using the application builder from a VI containing a MathScript node. This could be one way to get MathScript code into a shared library.
    The application builder is included with LabVIEW Professional Edition. You can setup a shared library by going to the project explorer and right clicking "Build Specifications" and selecting New->Shared Library (DLL).
    -K Scott

Maybe you are looking for

  • Office 2013 license pack does not allow me to activate key within configuration wizard

    Hello,  I have a KMS host running Office 2010 activations for our client computers which is running fine. I installed the Office 2013 license pack on the same host. However, in the configuration wizard it doesn't allow me to activate the product key.

  • Lightroom's 4 color "spaces"

    I’m working on designing an advanced photography course. This course makes use of Lightroom and Photoshop in the photographic workflow. I’m learning and researching myself as I go along, and I feel I have reached a ceiling on what I can work out from

  • Transaction code KOAB

    Transaction code KOAB is open for change even if client is closed. Will it be possible to change the setting of this transaction code so that , it will be open in change mode only when client is open.

  • ITunes artwork not downloading with file and tab blanked out.

    The last 4 items I have downloaded from iTunes (tv Shows and Movies) are not coming with any album art.  As the TV shows are on season pass its only the latest episodes that don't have artwork. Also the artwork tab is greyed out on the Get Info scree

  • Does Skype work with Mac

    Does skype work with mac