Mathscript NaN initialize array LV 8.6

For those of us who purchased LV 8.2-8.6 Mac OS Dev Suite, the mathscript module will not initialize an array with NaN.
That is,
c=nan(m,n)
and
repmat(NaN,m,n)
are broken.
The only work around I can find is to replace a number, such as "0":
InT=repmat(0,m,n); InT(=NaN;
Would appreciate any other work-arounds to create a m x n array of NaN.
Solved!
Go to Solution.

Hi wjdwyer,
This has been fixed in newer versions of MathScript, but for the older versions another potential workaround that I've come across is to multiply nan by an array that already exists (see below). I know this isn't ideal, but hopefully it will at least give you an alternative.
A = nan * repmat(1,m,n);

Similar Messages

  • What is the best way to create diagonal array in order to avoid MEMORY IS FULL error created by using INITIALIZE ARRAY vi?

    Using the values in a 1D array, I need to place them along the diagonal of a 2D array. Currently, I've been using INITIALIZE ARRAY VI to create 2D array of zeroes and then usE REPLACE ARRAY SUBSET to put the 1D array values on the diagonal. This works sometimes but I often get an error stating that the memory is full and that the application was stopped at INITIALIZE ARRAY.
    I'd appreciate any advice on how to stop this from occuring.
    Thanks and happy holidays,
    Hunter (LabView 6.1 user)

    Weather is the same here, too.
    Sorry about the PDF. I had forgotten about the PRTSCN option. See the attached JPG.
    I'd send you an example input that is giving me problems but today, my computer seems to be behaving and the error hasn't popped up. This makes me believe that it's truly a memory problem with my machine.
    This VI is a subVI used in several computationally intensive applications.
    If you're still interested in playing with it, I will email it to you. Please send me your address. In fact, I see you're in the oil & gas industry and I'd like to hear what you're working on since I work in that industry as well.
    Thanks again, Hunter ([email protected])
    Attachments:
    VI_Diagram.jpg ‏104 KB

  • Is it only one chance i can initialize array with int [] a={3,2,1}

    is it only one chance i can initialize array with int [] a={3,2,1}
    ===============================
    class InitializeArrayTest
         int [] a;     //i need keep a[] global
         public static void main(String args[])throws IOException
                   //a=new int[] { 3, 2, 1};//can not complie<========why here is wrong
                   a=new int[3];//also can not
                   a={3,2,1};     //I want to use {3,2,1} as data for simple test purpose here for other method
    }

    so if static means only one instance allowed
    for what reason there is no compiler error in the
    coding below
         static int [] preSort;
         public B(int i)
    int []preSort=new int; //<======why no syntax
    You are declaring a new local variable called preSort, which has scope to the end of the constructor.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Initialize array vs array constant

    j'ai besoin d'un tableau initialisé.
    de ces 2 options:
    - la fonction initialize array
    - une constante tableau
    quelle est la meilleure ? ... et surtout pourquoi.
    en terme de performance, de gestion mémoire (ou autres paramètres)
    Je me doute que si la fonction "initialize array" a été créée ... il y a sans aucun doute une raison
    mais quelle est-elle ? ... par rapport à l'utilisation d'une "constante tableau".
    merci à tous.
    edit:
    la fonction "initialize array" permet (en effet) de fixer dynamiquement la taille,
    serait-ce le "pourquoi" de son existence ?

    perso, j'utilise assez fréquemment la fonction "initialize array" dans les cas où je connais (à l'avance) la taille de mon tableau,
    ou plus précisément ... quand je connais la taille "maximum" de mon tableau.
    J'utilise toujours "initialize array" conjointement avec les fonctions "replace array subset" et "reshape array".
    comme ceci par exemple :
    je préfère de loin cette méthode plutôt que d'utiliser la fonction "build array" ... ou un tunnel d'indexation.
    C'est un peu plus de code, mais LV connait la taille du tableau dès la compilation ... et ça, c'est plus de vitesse.
    De plus ... (je n'ai pas vérifié) ... j'ai lu que le tunnel d'indexation était "relativement" lent. (et encore d'avantange avec le tunnel indexé conditionnel)
    Je ne fais pas d'acquisition, mais je pense que ce système n'est pas incompatible avec un code d'acquisition.
    Un acquisition se passe pendant un temps "fini", on connait (en principe) la fréquence d'échantillonnage,
    je ne vois donc pas d'interdiction de "prévoir" dès le début un tableau de taille connue.
    Mais ... je ne suis pas un spécialiste de l'acquisition.
    initialiser un talbeau 2D d'une taille de 20*5 avec la valeur 0 doit prendre moins de mémoire que d' initialiser un tableau de la même taille avec la valeur 1000
    là ... queneni ... initialiser un tableau x avec la valeur 0 ou 1000 occupe exactement le même espace mémoire.
    Les données se trouvent sur 32bits ... et notre mémoire centrale se moque de savoir si la valeur mémorisée est x ou y ... c'est toujours 32bits.
    1000 x U32, c'est 1000 x (4 octets) = 4000 octets dans tous les cas.
    Pour conclure, je dirais que la fonction "initialiser un tableau" ne sert qu'aux cas particuliers où l'on doit donner la même valeur pour un tableau
    avis pertinent.
    perso, je dirai que "initialize array" est utile quand on connait à l'avance la taille ou la taille maximum d'un tableau.
    mais ta vue des choses est intéressante.
    merci Kaleck0 pour ton intervention.
    Les discussions "de fond" sont toujours très intéressantes.

  • Initialize array from a constant string

    I generated the coefficients for a FIR filter in Mathscript (250 taps).  I dumped the values to a data file and then "load"ed them into a Mathscript box inside my vi. 
    This worked well until I created an executable version of my program (no Mathscript) where my coefficient vectors now come up Null.
    My idea is to text copy the coefficients into a string constant in my vi, and then initialize my array as part of my start-up routines.
    I was wondering if anyone has done this?  Is such a routine available anywhere?
    Thanks,
    Tom J

    How are you building the path the file that you are reading?
    When you build an executable, the path of the VIs it contains changes.
    In development environment, path to VI = c:\project\Top Level.vi
    In executable environment, path to VI = c:\project\Executable.exe\Top Level.vi
    So if the file you are reading is in the same directory as the executable, and you are building a path relative to that, you need to strip one more path level for the executable.
    The above image shows one way to do determine programmatically if you are in the development or executable environment and how to strip the path an extra time for the RTE.
    If this is not the problem, kindly ignore everything I just rambled on about.
    Ed
    Message Edited by Ed Dickens on 02-22-2007 10:36 AM
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    Strip Path RTE.gif ‏4 KB

  • Mathscript node and arrays

    hello, I am new to LabVIEW, so I need ur help. I want to provide some controls to mathscript window and it has to output an array/matrix.. Please help me.

    Raghavendra1 wrote:
    hello, I am new to LabVIEW, so I need ur help. I want to provide some controls to mathscript window and it has to output an array/matrix.. Please help me.
    You always choose datatypes for input and output, can you give little more info about your program or vi what exaclty you want to do.
    check this also:
    Developing Algorithms Using LabVIEW MathScript RT Module: Part 1 – The LabVIEW MathScript Node

  • How to initialize array variable generated by Rosetta

    Hello,
    I have
    pl/sql types :
    TYPE xxg2c_pe is record (quota_name clob,revenue_class_name varchar2(30), performance_type varchar2(150),
    rate_table_name varchar2(80), formula_name varchar2(30),package_name varchar2(30) );
    TYPE xxg2c_pe_tab is table of xxg2c_pe;
    pl/sql procedure:
    PROCEDURE check_redundancy_pe(
    p_org_id IN cn_quotas_all.org_id%TYPE
                   ,p_comp_plan_id IN cn_quota_assigns_all.comp_plan_id%TYPE
    ,p_pe_tab OUT xxg2c_pe_tab
    ,x_return_status OUT varchar2
    ,x_msg_count OUT number
    ,x_msg_data OUT varchar2
    the signature generated by Rosetta:
    public static void checkRedundancyPe(
    OracleConnection _connection,
    BigDecimal p_org_id,
    BigDecimal p_comp_plan_id,
    Xxg2cPe [][] p_pe_tab,
    String [] x_return_status,
    BigDecimal [] x_msg_count,
    String [] x_msg_data
    ) throws SQLException :
    I call this method in java:
    xxg2cCompPlanUtilsPkg.checkRedundancyPe(
    conn,
    new BigDecimal(getOADBTransaction().getOrgId()),
    new BigDecimal(compPlanId),
    quotaTAB,
    returnStatus,
    msgCount,
    msgData);
    But before I call this method, I need to initialize quotaTAB as:
    Xxg2cCompPlanUtilsPkg.Xxg2cPe quotaTAB [][] = new Xxg2cCompPlanUtilsPkg.Xxg2cPe[size][6];
    Since quotaTAB is an output parameter, before I call the method, I don't know its size, so what size do I need to put for initialization?
    thanks for your help.
    Lei

    Hello,
    I have
    pl/sql types :
    TYPE xxg2c_pe is record (quota_name clob,revenue_class_name varchar2(30), performance_type varchar2(150),
    rate_table_name varchar2(80), formula_name varchar2(30),package_name varchar2(30) );
    TYPE xxg2c_pe_tab is table of xxg2c_pe;
    pl/sql procedure:
    PROCEDURE check_redundancy_pe(
    p_org_id IN cn_quotas_all.org_id%TYPE
    ,p_comp_plan_id IN cn_quota_assigns_all.comp_plan_id%TYPE
    ,p_pe_tab OUT xxg2c_pe_tab
    ,x_return_status OUT varchar2
    ,x_msg_count OUT number
    ,x_msg_data OUT varchar2
    the signature generated by Rosetta:
    public static void checkRedundancyPe(
    OracleConnection _connection,
    BigDecimal p_org_id,
    BigDecimal p_comp_plan_id,
    Xxg2cPe ][ p_pe_tab,
    String [] x_return_status,
    BigDecimal [] x_msg_count,
    String [] x_msg_data
    ) throws SQLException :
    I call this method in java:
    xxg2cCompPlanUtilsPkg.checkRedundancyPe(
    conn,
    new BigDecimal(getOADBTransaction().getOrgId()),
    new BigDecimal(compPlanId),
    quotaTAB,
    returnStatus,
    msgCount,
    msgData);
    But before I call this method, I need to initialize quotaTAB as:
    Xxg2cCompPlanUtilsPkg.Xxg2cPe quotaTAB [] [] = new Xxg2cCompPlanUtilsPkg.Xxg2cPe [size][6];
    Since quotaTAB is an output parameter, before I call the method, I don't know its size, so what size do I need to put for initialization?
    thanks for your help.
    Lei
    Edited by: user571830 on Feb 13, 2009 1:48 AM

  • Java Array initialization

    I am in a Java class and one of the problems that we have been given as homework is stumping me. It wants us to use a stack containing int triples ( i, j, k ) to initialize n values of an n X n array. The trick is that we can't initialize the array normally ( int[][] A = new int[n][n] ) because we don't want a *O[n^2^]*.
    My question is, how can I create an n X n array without setting the initial values to zero and still be able to use it in the program?

    Maybe your prof thinks Java doesn't initialize arrays. The C++ trick went as follows:
    1. Create an NxN matrix m (of garbage values).
    2. Create 3 size N arrays row, col and value: zero them out -- O(N).
    3. Maintain a count cnt of the number of values stored so far -- initially 0.
    4. To "set" x in m[r][c], acutually store cnt in m[r][c]; then set:
    row[cnt] = r
    col[cnt] = c
    value[cnt] = x
    then increment cnt
    5. To "get" the value stored in m[r][c], examine the actual value stored there.
    Call it z. If z<0 or z>=cnt, z is garbage, so the real value is 0. Otherwise
    we need to look at z more closely. Check if row[z]=r and col[z]=c. If so, the
    value stored is value[z]; otherwise z is still garbage and the real value is 0.
    Easy-peazie.

  • How to declare and initialize a STRING ARRAY (assign strings to array elements)

    How to declare and initialize a STRING ARRAY (assign desired strings to elements of an array, for example "abc", "def", "ghi", "jkl", etc.) in LabVIEW? I saw a "string array" block in help, but could not find it in the function palette. Does a spreadsheet string have to be in a file (or can it be in a string constant block)? Thank you.

    Hi,
    you can do it in several ways:
    1. Direct way: Create string array control on front panel and type strings in its elements
    2. Programmatically 1: Create string array indicator (or local variable of control), right click on it in block diagram, select "Create constant" from drop down menu. The array constant will appear. Now type values in this constant's strings
    3. Programmatically 1: Use "Build array", "Replace array subset", "Insert into array" or "Initialize array" functions from "Functions->Array" palette.
    And of course you can combine all of these methods.
    Good luck.
    Oleg Chutko.

  • Initializi​ng arrays

    Hello!
    I'm doing a program which works with arrays. I use initialize block arrays to create them. But it depends on other variables the dimension of these arrays. If I want to change the length of a dimension I wire a variable to the block, but I have no idea what can I wire to the block to modify the number of dimensions....it cannot be modify when the program is running?? How I have to do modify the number of dimensions depends on a variable?
    Thank you in advance!
    Larson

    The initialize array function is a growable function, that is it changes the function inputs by dragging the dimensions not programatically.  There is a work around, you can use a case structure to call different versions of the function.  This will work but will only for a finite number of cases.  The other way is to initialize a multidimensional array as a single dimension and then pass it to the resize array function, i.e initialize ARRAY[i*j*k] and resize to ARRAY[i][j][k].  This is a little unusual to deal with arrays which change at runtime.  The final approach it to write polymorphic functions to handle the different cases, again you will not have full dynamic run-time handling of all possible cases but can handle a few cases easily.
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • How to build an array based on inputs from a text file

    Hi
    I have ta text file that has the following format. The apmlitude is the first value then I have the start index number and last index number
    Other index values in between should be zero
    (amplitide, start index number, end index number)
    2, 2 ,3
    4, 6, 7
    5, 10,11
    using this format I should make the foloowing array
    0,0,2,2,0,0,4,4,0,0,5,5
    Could you please help me to implement it in LabVIEW
    Thanks

    A few notes:
    - You'll want to use the Initialize Array function for 1) and 3) (if this is, in fact, how you want to do this.)  This function takes two inputs when initializing a 1D array- element value and array size.   
    - Change the polymorphic instance of Read From Spreadsheet File.vi to "Double" or "Integer"- there's no reason to read in these numeric values as strings and convert them later.
    - Will the text file always contain 12 elements worth of data?  If not, you'll need to change your logic for the number of elements to initialize.
    As Altenbach said, this seems a lot like a basic logic/homework problem.  My suggestion was only that-a suggestion.  It is not the only way to do this. Figure out a sequence of steps to get you from point A to point B before you jump in and start coding. 
    Regards,
    Tom L.

  • How to ask for an array and how to save the values

    I'm supposed to be learning the differences between a linear search and a binary search, and the assignment is to have a user input an array and search through the array for a given number using both searches. My problem is that I know how to ask them how long they want their array to be, but I don't know how to call the getArray() method to actually ask for the contents of the array.
    My code is as follows:
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How long would you like the array to be?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            System.out.println("Please enter the first value of the array");
        public static void getArray(int List[], int arrayLength)
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter the next value for array");
                 List[i] = input.nextInt();
         public static void printArray(int List[])
             for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
    public class search
        public static int binarySearch(int anArray[], int first, int last, int value)
            int index;
            if(first > last) {
                index = -1;
            else {
                int mid = (first + last)/2;
                if(value == anArray[mid]) {
                    index = mid; //value found at anArray[mid]
                else if(value < anArray[mid]) {
                    //point X
                    index = binarySearch(anArray, first, mid-1, value);
                else {
                    //point Y
                    index = binarySearch(anArray, mid+1, last, value);
                } //end if
            } //end if
            return index;
        //Iterative linear search
        public int linearSearch(int a[], int valueToFind)
            //valueToFind is the number that will be found
            //The function returns the position of the value if found
            //The function returns -1 if valueToFind was not found
            for (int i=0; i<a.length; i++) {
                if (valueToFind == a) {
    return i;
    return -1;

    I made the changes. Two more questions.
    1.) Just for curiosity, how would I have referenced those methods (called them)?
    2.) How do I call the searches?
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How many values would you like the array to have?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            //Collects the array information
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter a value for array");
                 List[i] = input.nextInt(); 
            //Prints the array
            System.out.print("Array: ");
            for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
            //Asks for the value to be searched for
            System.out.println("What value would you like to search for?");
            int temp = input.nextInt();
            System.out.println(search.binarySearch()); //not working
    }

  • How can I keep all the previous datas in the same array?

    I have a problem with keeping the previous datas in my array. The problem is when the iteration loop is executed, I have one or two value(s) stored in the array. The second iteration I have either one or two values (depending on the condition) coming out, but it overwrites my previous value. I want to keep all my data in the same array as the loop is executed.PS. I have attached a simple vi along this message. If anyone can help me out with this, I really appreciate for the help.
    Regards,
    Sonny

    If you iterate several times (N > 100) then I would suggest using the Initialize Array outside of the For Loop and then use the Replace Array Subset inside the Loop to populate the array. The reason for this is because the Build Array utility has to locate a new space in memory for the newly concatenated array -- the Replace Array Element utility uses the same memory space.
    If you iterate just a few times with a small array then using the Build Array should be okay.
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

  • Arrays greater than 0 and taking only the elements that doesn't contain that

    Hi, I have 6 arrays.
    X-Axis, Y-Axis, PressRef, TempRef, PV, and VecorPress.
    I have created a spreadsheet for them using txt
    When I use colum 1 (X-Axis) Vs. column 2 (y-axis) to plot in an XY graph in excel, I want to delete all ELEMENTS that have the value ZERO on my X-axis.
    Meaning that all the elements of X-axis that are 0's.
    For example..
    I have X,Y,Z
    130     15   16
    130     15   17
    0         16   17
    131     16   17
    When I have it in my text. I only want to see this
    130     15   16
    130     15   17
    131     16   17
    I have a diagram picture of what i currently have and then i have a txt file that i currntly have. can someone help me?
    thank you
    Best regards,
    Krispiekream
    Attachments:
    Image2.jpg ‏76 KB
    New Text Document.txt ‏158 KB

    The OpenG functions can be found from the OpenG site. They save you the trouble of having the code some stuff up yourself.
    The "code it yourself approach" using a temporary 2D array looks like this:
    Note: As I said, there will be some memory thrashing as LabVIEW allocates memory for the growing 2D array. The alternate method I described would use "Initialize Array" to create a 2D array and then use Replace Subset to "insert" the rows into the 2D array. I will leave it as a learning exercise for you to code that up.
    Message Edited by smercurio_fc on 11-05-2007 05:15 PM
    Attachments:
    Example_BD.png ‏14 KB

  • C++ tab delimited file to array

    Converting a large tcl project into c++ and i am struggling with the simplest tasks. For example, i used to create array of data from my file using the following method.
    .debug.t insert end "Reading Well Data\n" ; update
    set fileId [open data/$welldat r]
    set wcntr 0
    set welllist ""
    gets $fileId line
    while {[gets $fileId line] >=0} {
      scan $line "%s %s %f %f %f %f %f %f" wellid well xsurf ysurf xbh ybh elev td
      incr wcntr
      set wida($well) $wellid
      set wella($well) $well
      lappend welllist $well
      set xsurfa($well) $xsurf
      set ysurfa($well) $ysurf
      set xbha($well) $xbh
      set ybha($well) $ybh
      set eleva($well) $elev
      set tda($well) $td
    close $fileId
    Here is what i have so far in c++. Dont laugh i am using what is being taught at a community college class. Pretty basic stuff.
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <sstream>
    using namespace std;
    int main()
            //Initialize temp Variable to hold lines and entrys.
            string fileLine = "";
            string tempEntry = "";
            //Initialize Arrays for wells.txt file
            string wellName [] = {""};
            long wellApi [] = {0}, tempAPI = 0;
            double surfaceX [] = {0.0}, surfaceY [] = {0.0}, bottomX [] = {0.0}, bottomY [] = {0.0}, kellyBushing [] = {0.0}, totalDepth [] = {0.0} ;
            //Create input file instance
            ifstream inWells;
            //open file
            //File format is a tab dilimited file
            //Well label, api, surface x coord, surface y coord, bottom x coord, bottom y coord, kelly bushing elevation, total depth of well
            inWells.open("wells.txt");
            //no else to check for failed open file.
            if(inWells.is_open())
                //intialize counter set to zero
                int fieldCounter = 0;
                //exits the loop when line is no longer good.
                //loop starts
                while (!inWells.eof())
                    //get the entire line and store it in a variable fileLine.
                    getline(inWells,tempEntry,'\t');
                    cout << fieldCounter << " " << tempEntry << endl;
                    fieldCounter ++;
            //end if
            system("pause");
    right now i was just trying to print each of my parsed entry's. Then i was going to add the data to the array's but for some reason when i print the data i donot get a counter on the 1st entry of each line.
    Example data
    THOMPSN_J__TERRILL_ST_272-#1    42389100990001    1015951.28    583865.59    1015951.30    583865.60    2681.00    21368.00
    PANTHER_EX_KIMBER_GAS_17-#1    42389303410000    962142.94    571723.08    962142.90    571723.10    2829.00    14640.00
    INDREX_INC_CONOCO_STA_20-#1    42389312220000    961498.99    566401.78    961499.00    566401.80    2841.00    14386.00
    NEWPORT_PE_ALAMO_GIN_14-#1    42389313420000    962094.09    575749.87    962094.10    575749.90    2814.00    15316.00
    SHELL_WEST_HOEFS_52-2_23-#1    42389326050000    1008181.09    548865.88    1008181.10    548865.90    2802.00    10900.00
    OXY_USA_WT_BUSH_13-25_253-#1    42389326170000    1003471.84    582962.26    1003471.80    582962.30    2708.00    12590.00
    OXY_USA_WT_HENDRICK_S_254-#1    42389326180000    1004569.07    586773.12    1004569.10    586773.10    2701.00    12795.00
    PRIMEXX_OP_PISTOLA_186-#1    42389326270000    986849.60    559777.62    986849.60    559777.60    2745.00    12600.00
    PRIMEXX_OP_BELL_213_213-#1    42389326350000    992022.77    558517.55    992022.80    558517.60    2760.00    12674.00
    PRIMEXX_OP_CAPPS_214__214-#1    42389326360000    990737.88    553380.84    990737.90    553380.80    2790.00    12084.00
    OXY_USA_WT_POLO_GROUN_150-#1    42389326430000    983009.38    566162.59    983009.40    566162.60    2744.00    13500.00
    OXY_USA_WT_EBBETS_14_149-#1    42389326560000    983502.05    568782.50    983502.10    568782.50    2727.00    12500.00

    On this or this or
    other similar sites you can find helping hands for your project.
    --pa

Maybe you are looking for