Initializing Array in a Unique Manner

Hi All,
I'm new on this and have tried for several hours how to do the following "simple" thing without any success. I'm using a cDAQ 9171 with a NI 9263 analog output module.
My Problem: I need to start the following program when Start button is pushed. Please, in order of priority I'm giving you what I have to do.
1. Analog output from an array that haves fixed values. Let it be 5 ; 4 ; 3 ; 2 ; 3 ; 4 . So I need to stay 1min in each value and then repeat the whole array for  10 times more.
I Tried with the attached project, but it only generated a 1V signal, even when the appended array was changing...I don't know what happened.
2. I wanted to create automatically the array i mentioned before. But it gave me so much headache that i left it.
Thanks in advance for your help.
Solved!
Go to Solution.
Attachments:
v0.3.zip ‏24 KB

Take advantage of auto-indexing tunnels to break out the data in your array.  And if you use 1 channel 1 sample rather than N channels 1 sample, you won't need to take that scalar value and build it back into an array.
Attachments:
fte v0.3MOD.vi ‏37 KB

Similar Messages

  • Initializing array of Object T

    Is there any way to initialize an array using the class tokens?
    In my case I want to create a new T[100]; without (initializing any specific elements that is) - it does not seem to function very well...

    Not really, because T isn't known at run time (erasure) so you can't create an array of a specific type this way.
    If you've got a class object for T you can use Array.newInstance() and cast it to
    T[]. (Though you'll get an "unchecked cast" warning).

  • Initializing array of objects

    This is my beginning effort to initialize an array of objects, but the compiler messages seem to lead me astray. What is the easiest way to do this, or can't it be done in a manner similar to this?
    Do I have to do it from a program loop or something?
    private static void testWidNum() {
    class testPair { double dbl; int nsf; }
    testPair[] testNums = new testPair[] { {999999999.,5}, {9999.,5} };
    This should be an easy answer, compared to the one to which I didn't get any reponses.
    dewayne

    Probably I may write it like this.
    public class SomeClass
      private void testWidNum() {
        testPair[] testNums = new testPair[]{
                                       new testPair(9999, 5),
                                       new testPair(9999, 5),
                                       new testPair(9999, 5)
    class testPair{
        testPair(double _dbl, int _nsf)
            dbl = _dbl;
            nsf = _nsf;
       double dbl; int nsf;
    }

  • Initializing array of user-defined class

    I have a need to make an array of my own classes, simply to make a database organized.
    First, I defined my class at the start of the program:
    public class FBase
    String FName = "";
    String FDate = "";
    int FNameLength = 0;
    int FDateLength = 0;
    int status = 0; // value of 0, 1, 2
    } FExample = New FBase;
    This gives me one instance of the class, FExample.
    Now I can store data thus:
    FExample.FName = "Jones";
    FExample.FDate = "1934";
    FExample.FNameLength = 5;
    FExample.FDateLength = 4;
    FExample.status = 2;
    What I would like is an array of such instances of this class.
    I have followed the standard procedure for initializing an array, but my efforts are not accepted.
    In place of the line above initializing one instance in FExample, I have tried -- both at the top of the program and in public void init() -- the following code:
    FBase[] Example = New FBase[200];
    FBase Example[] = New FBase[200];
    FBase[] Example;
    Example = new FBase[200];
    None of these are accepted. How do I do this?

    Alright -- I found one problem and solved it, but I still have another problem, pretty much the same problem I thought I was facing at the start, but now a little better defined.
    At first, my class did not work even with one instantiation, let alone when I tried to instantiate an array of the class. I dound that I did not have a constructor, and I need a constructor if I am to create an instance of the class (I am learning ...). So, the class now looks like this:
    public class FBase
    String FName = "";
    String FDate = "";
    public FBase(){} // constructor
    Now the following line of code works:
    FBase FExample = new FBase();
    I am able to use FExample.FName and FExample.FDate as proper variables.
    My problem still exists when I try to instantiate an array of the class. In place of the above line of code, I have tried this:
    FBase[] FExample = new FBase[200];
    The compiler accepts it, but now FExample[0].FName and FExample[0].FDate are not recognized as proper variables, and nothing goes on when I try to use them in the program.
    Any ideas?
    Edited by: vanhoey on Jun 27, 2008 12:38 PM
    Edited by: vanhoey on Jun 27, 2008 12:40 PM

  • Initializing array elements on a static initialization block

    Hello,
    I have this class:
    class Foo{
        public static Wing[] flights = new Wing[20]; //initialize with null Wing references
        static { //static initialization block - begin
            for(Wing w : flights){ //for each Wing slot on the array,
                w = new Wing();      //create a Wing object and refer to it
            } // static init block - endThe code above creates a Wing array, and the static init block should create 20 Wing objects on the array slots, but the objects are lost when I try to use it in the main method on the same class Foo:
        public static void main(String[] args){
             System.out.println(flights[3].name); //will throw NullPointerException -> Array elements have not been initialized  
        }How is that possible? The init code for(Wing w : flights) looks like has created copies of the objects, and not just references to the same object. If I change the static init block to the "old-fashioned for loop"
    for (int i=0; i < flights.length; i++){
    flights[i] = new Wing();then it works.
    But I think that the problem is not on the kind of for loop itself, because if I use same static initialization statement, with for (Wing w : flights) on the main method, instead of in a separate init block, the array gets populated with solid objects.
    Any ideas of what I am doing wrong?
    Java version: 5.0

    I think I got it. I am reseting the reference to point to a new Object in the heap instead of the array slot. :-P

  • Initializing array constructor to 0

    I have created a stats class, but I am not sure how to initialize the array constructor to be all zeros. It is a single interger array that can hold 50 values.

    int[] array = new int[50];Each array element will be initialized to zero.
    The Java� Tutorial - Arrays

  • Initializing arrays with non-default values

    Hi,
    I have a large array (300+ elements) and want it to be filled with all -1 at the start and not with 0.
    A couple of (bad) ideas of mine:
    - using an expression "array[0] = -1, array[1] = -1, ..." (a lot of typing work)
    - using a for loop with an expression "array[Locals.k] = -1" (very slow)
    - getting the array from "somewhere else" like e.g. a LabVIEW VI (cumbersome)
    Is there some expression syntax I can use?

    You can use SetElements(Locals.d,-1)  where d is the array.

  • Initializing arrays?

    Hello!
    In a VI have an empty 2D-array (3 columns, x rows),
    in which I want to insert a new row. The first time
    I start the VI, the row is correctly inserted. When
    I start the VI again, the array-insertion-VI doesn't
    insert anything. Ideas if I have to initialize
    the target array in any way?
    Thanks in advance, Michael.

    Hi,
    if the array is a front panel control/indicator you have to fill in some data in that area (even if it's 0.00) to "activate" those cells for future use.
    To be sure that everything it's done properly, initialize the array with default values for a specific number of rows and columns before any other operation.

  • How to insert a 2D array into the end of X axis of the initial array?

    Hi, friends, I have a question and look for an advice. I have several input data, each of which has 4 rows and unknow columns. Each time I receive the input, I need to combine it to all of the previous ones by adding it to the end of X axis of the previous combined data. I must do it because, later, I need to run my model and my model read input for each column of 4 rows. How should I do it? Also, should I initiate an array before reading all of the inputs? The inputs are F32 format. Thank you very much for any of your advice.

    Building a 2D array row-by-row is easy. You either use "build array" if you need to update the indicator during the run, or you simply autoindex at the loop  boundary (FOR or WHILE).
    Two possibilities are shown in the attached image. If your arrays are getting large and you use a while loop, there are possibilities that are more memory efficient. You would initialize a 2D array (e.g. filled with NaNs) of an upper boundary of the final expected size, then replace rows as you go.
    (Notice that if you use autoindexing on a FOR loop, the final size is known from the beginning so memory can be allocated efficiently)
    Message Edited by altenbach on 11-01-2006 09:19 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AppendRows.png ‏5 KB

  • Initializing Array of JLabels

    This one's got me scratching my head. The critical lines of code are:
         final JLabel[] labelTable = new JLabel[3][9];
         labelTable[0][0] = new JLabel("Item Name");And then there are several more lines like the second. The problem I'm having is that, on every line like the second, I get two errors: one complaining that there isn't a closing ] immediately after the very first opening one, and then another error that I just assume is caused by the first error FUBARing the line's syntax.
    Why on earth would the compiler not want a value in the array element brackets? I did just create the array, right? It knows labelTable is an array, or it should...
    I've tried removing the "final", and I've tried removing the " = new JLabel[3][9]", and neither fixes the problem. Any ideas?

    There's not a lot more than what I've already provided...
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Gui implements ActionListener {
         final JLabel[][] labelTable = new JLabel[9][3];
         labelTable[0][0] = new JLabel("Item Name");
         labelTable[0][1] = new JLabel("Cost");
         labelTable[0][2] = new JLabel("Reserved By:");
         /* What follows will be replaced by a file read when I'm good and ready. */
         labelTable[1][0] = new JLabel("Book about Cheez-Its");
         labelTable[1][1] = new JLabel("$$");
         labelTable[1][2] = new JLabel("Santa Claus");
         labelTable[2][0] = new JLabel("Amazing Electronic Gadget");
         labelTable[2][1] = new JLabel("$$$");
         labelTable[2][2] = new JLabel("none");
         labelTable[3][0] = new JLabel("Ye Holye Thumbtack");
         labelTable[3][1] = new JLabel("$");
         labelTable[3][2] = new JLabel("Clarence Thomas");Those are lines 7 through 26. The lines before 7 are a documentation comment. The lines after 26 are standard, straight-out-of-the-Tutorial methods for implementing the rest of the GUI (look'n'feel String, initLookAndFeel(), createAndShowGUI()...) and also setting a couple rows of buttons. The code for the buttons compiles fine. I just get 24 errors corresponding to those twelve initializations of labelTable[x][y].

  • URGENT - initializing array

    how can i copy the values from a fime into an array ?

    Oh I see. File.
    That depends on the data type of the array... do you want to store Strings, int, Objects...?

  • Initializing Array

    Why does this work:
    public class Test
         private int[][] array;
         public Test()
              int[][] a =
              {{0, 1},
               {1, 0}};
              array = a;
    }But this doesnt:
    public class Test
         private int[][]array;
         public Test()
              array =
              {{0, 1},
               {1, 0}};
    }Thanks ahead of time.

    Just to correct my terminology here - and I think it gives an insight into why the legal syntax is defined in that particular way - I should have said that the code I posted "assigns the reference to point to a new array object with those values" rather than that it "reinitializes" the array.

  • Newbie to Flex...Arrays of Strings

    I have an XMLListCollection that is populated from a database
    that contains census data. Each entry is a person with a race,
    occupation, marital status, family size, and year. I want to make
    an array of either objects or strings (I don't really care, as long
    as it works) where each entry in the array is a unique field value.
    For instance, if my database contains people that have family sizes
    of 3, 4, 5, 4, 4, 3, 4, and 5, then I want my array to have 3
    values, 3, 4, and 5. Right now, the code doesn't deal with
    duplicates, but once I have it so that it makes an array of strings
    of the values themselves I'll deal with the duplicates. The
    database is initially loaded into the stats XMLListCollection.
    To accomplish this, I have the attached code.
    The display is as follows: The first label outputs 27, which
    is correct since that's how many items I have to put in the array.
    The list is populated correctly, with all the years displaying as
    they should. The popupmenu is empty, which boggles my mind. And
    finally the length of the years array outputs as 0. I am very, very
    confused as to why any of this happens. Help, please.

    The problem you are running into is because you are using an
    Array instead of an ArrayCollection. Arrays do not broadcast
    updates when there data changes which is the biggest advantage in
    my opinion of why you would want to use an ArrayCollection. Example
    as follows to illustrate my point.

  • Desperate HELP with Random Numbes in an Array & Do / While

    Please somebody help, I have been working this problem for over 7 days now and can't get it. I have tried everything from a while to a do while to this and that. I need to have an Array of 8 that when run will produce random numbers for output between 15 to 25. I CAN"T GET IT PLEASE HELP. I am new to JAVA and have done everything I can think of to resolve this. I even have purchased a new book and looked at every site trying to find a solution. PLEASE HELP! Here it is:
    import javax.swing.*;
    public class RandomArray{
    public static void main (String [ ] args) {
    JTextArea outputArea = new JTextArea ( );
    int myArray [ ]; //array declaration
    myArray = new int [ 8 ]; //allocating memory
    String output = "Array values at initializatioon ";
    output += "\nIndex\tValues";
    for ( int i = 0; i < myArray.length; i ++)
    output += "\n" + i + "\t" + myArray [ i ];
    output += "\n\nArray values after assigning values within the range of 15 and 25";
    do {( int i = 0; i <myArray.length; i++)
         while     myArray [ i ] = 15 + (int) (Math.random ( ) * 25);
    output += "\n" + i + "\t" + myArray [ i ];}
    outputArea.setText (output);
    JOptionPane.showMessageDialog (null, outputArea,
    "Array Value before and after",
    JOptionPane.INFORMATION_MESSAGE);
         System.exit ( 0 );
    The output that I need is in two columns one with the initial array 0-7 and the second should be random numbers 15-25. Please help, please

    here you are :
    import javax.swing.*;
    public class RandomArray
    public static void main (String [ ] args)
         JTextArea outputArea = new JTextArea();
         int       myArray [] = new int[8];
         String output = "Array values at initializatioon ";
         output += "\nIndex\tValues";
         for (int i = 0; i < myArray.length; i ++)
              output += "\n" + i + "\t" + myArray [ i ];
         output += "\n\nArray values after assigning values within the range of 15 and 25";
         for (int i = 0; i < myArray.length; i++)
              myArray [ i ] = 15 + (int) (Math.random ( ) * 10);
              output += "\n" + i + "\t" + myArray [ i ];
         outputArea.setText(output);
         JOptionPane.showMessageDialog (null, outputArea,
              "Array Value before and after",
              JOptionPane.INFORMATION_MESSAGE);
         System.exit(0);

  • Is there a null value that I can put into a byte array?

    I have a byte[] that I'm trying to make smaller, at the moment, in order to do so, i'm writing it byte-by-byte to another byte[] called temp. Both are set to the same size, because I don't know exactly what the initial array will compress to.
    For example, my method will write a single byte that will tell the decompressor to carry out the next instruction 5 times (eg aaaaa = 5a), but after the instruction, I want to set the 4 a's afterwards to an empty value so that I can then iterate through temp, finding out how long to make the output byte[] by counting how many null's there are.
    Eclipse is telling me null is not possible to use, I was just wondering if there is an equivalent I can use?

    That's an idea!
    The only thing is then when I come to iterate through the byte array to write it to my output array, it throws up an error that I'm trying to compare a byte to a byte[]:
              int next = 0;
              byte[] n = new byte[0];
              for (int i = 0; i < temp.length; i++) {
                   if (temp[i] != n) {
                        output[next] = temp;
                        next++;
              return output;

Maybe you are looking for

  • Location of Links in PDF document

    I have a requirement, where I need to be able to find location (X,Y coordinates) of hyperlinks in the PDF document. I understand I can convert PDF to text or XML but that does not provide me location of hyperlinks. Any help will be appreciated. Thank

  • Reformatting My Nokia 6020?

    Anyone know how to do it?

  • Adapter Metadata Information Missing

    Hi XI Guru's , Recently i installed PI 7.0 successfully . At the time of configuring a scenario in Integration Directory my developer is not getting the Adapter metadata information via the drop down tool (i.e.  the tool by which we choose the adapte

  • Separating one iTunes account and content into two

    My partner and I are going through a divorce but we have shared the same iTunes account for the past 12 years. How do we separate our music library into two separate accounts so we can each have a portion of the library?

  • Sending chat message

    hi...       It is possible to send a chat message to a perticular ip address.if there is any class or function module available for it.       i checked chat program...please help me who to run the chat program.......