LabView, Storing in array some dynamics variables (ENG - FR)

(Version française plus bas)
Hello,
I have made a tiny .vi for using DAQ USB in analog acquisition of sine.
I want to store each step of test in one array. But when I start a new measure , it erase the old one.
Sorry for my bad english
Bonjour,
Je suis actuellement entrain de mesurer des dephasages grâce au DAQ de LabView. J'aimerai sauver mes différentses phases de test dans un tableau mais à chaque nouveau test les valeurs sont écrasées.
Merci d'avance pour vos conseils
Solved!
Go to Solution.
Attachments:
Aquis_boucle_liught.vi ‏142 KB

The stop button does not work because you have a dataflow problem. The stop button gets read exactly once at the start of the program, and then never again because the inner loops never stop. Once the inner loop starts, the outermost loop does not iterate until all inner loops have completed. This also means that the stop button will not get read. If you want a button to get the updated value inside an inner loop, the terminal needs to be inside the inner loop.
If all three of your buttons are off, you have three inner loops that execute empty cases, each as fast as the computer allows, consuming all available CPU. The loops need a small wait. See also.
You really need to learn about dataflow and design patterns. You code could be simplified dramatically. It is way to chopped up and inside out.
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • Problem in assigning script array to Js variable

    There is a huge list(20,000) of cities that has to be put into a script array for the further use in the jsp page. so this script array is created once for all when the login is made for the application and stored a session variable. The sample of the script array is like-----
    <script>
    strArrCityName[17463]= "Zoar";
    strArrCityID[17463]= "10599";
    strArrCityStateID[17463]= "3";
    strArrCityName[17464]= "Zoarville";
    strArrCityID[17464]= "10600";
    strArrCityStateID[17464]= "3";
    </script>
    the entire stuff from <script>---</script>(uncluding the script tags is stored as a string in the session (strSessionCityArr))
    Now the porblem is i need to store this array into a js variable on jsp page load.
    I order to that i need to declare a js variable in jsp page
    ex::
    <html>
    <body>
    This is a sample jsp page created by <%= strUserName%>
    <script>
    var cityarry = "<%=session.getAttribute('strSessionCityArr')%>";
    </script>
    </body>
    </html>
    when i assign the array to the js variable , the <script> tag inside the string is conflicting with the <script> tag that of the jsp page.
    This throws the js error and the futher loading of the page is stopped.
    The reason i am storing it in the js variable is i will be painting the script array dyanamically on click of a button.
    Also in need both the script tags in the array is in other jsp pages i will painting the array on page load by using the out.println(strCityArray)
    I need a way in which this script array can be stored in js variable or any method by which i can directly get it from the session on button click
    Thanx in advance
    Manu

    i had tired constructing the script array using the JS but JS logic is always slower ...my point was not to do it all with JS code. My point was that unless you know how to properly define it as JS-only code, then it makes it hard to figure out how to break that up to Java generated code. It's clear to me that you don't have a very good grasp of what you're trying to do.
    The second point is, in some JSPs i need the <script> tags to be included in the array. No they don't. You can always put the <script> tags around what your Java variable includes if you are using that content in several places...
    <script><%= session.getAttribute('strSessionCityArr') %></script>

  • How to create an array containing shared variable values

    Hi
    I am trying to programmatically create an array containing shared variable values and their names.  I can get the variable names by supplying the process name to the get shared variable list function.  How do I then read the value of all the shared variable items returned?
    I have used a data socket open to open a connection to all variables when my program starts.  I then use datasocket read on the opened connections to write to an array.  This works fine until I try to write to one of the variables using a shared variable node.  The variables writes can take from 4secs to 2 mins.  When I remove the shared variable node again all is fine.  Also when I stop using the data sockets, all is fine.
    Is there a conflict between shared variable nodes and data socket writes to the shared variables?
    Can anyone help?  I cannot easily post example code because I am reading the variables from a Wago PFC (PLC) using OPC.

    Hi
    Sorry I forgot to mention the LabVIEW version, its 8.20.  I have tried saving the shared variable node as a sub VI and it makes no difference.
    Attached is a stripped down version of the software.  You will not be able to connect to the IO server because it requires some Wago hardware and software.  You may spot something I have done wrong with the I/O servers, variables or sub VI's.
    The main program that runs is called 'HMI Engine' in the 'Framework' folder.  There may be some other things in the project that aren't used in this example.  I have removed all but the variable connection part of the code.
    I hope someone can help!?
    Thanks
    Mark.
    Attachments:
    HMI Test.zip ‏144 KB

  • How can I convert the variable expression stored as string back to variable expression

    How can I convert the variable expression stored as string back to variable expression?
    I am storing the expression enterd in the TSExpresssionEditControl as simple string and want to convert back to expression since I want to get the data type of that expression.

    pritam,
    I'm not sure what you're trying to do exactly. If you are trying to get the value of a variable and you only have the name of value in a string, then you can use Evaluate() to get its value. If you want the data type, my advise is to use the GetPropertyObject() API method and just pass in the loop up string. Then you'll have a handle to the data object and then proceed from there.
    Regards,
    Song D
    Application Engineer
    National Instrument
    Regards,
    Song Du
    Systems Software
    National Instruments R&D

  • Storing an array of checkbox booleans into preferences and retrieving them

    Just wondering how to go about storing an array of JCheckBoxes into a preference and retrieving it. There's 32 checkboxes so if they select, say, 6 of these randomly it should store it in a preference file and retrieve it when the application is loaded so that the same 6 checkboxes remain selected. I'm currently getting a stack overflow error, though.
    import java.util.prefs.*;
    public class Prefs {
         Preferences p;
         GUI g = new GUI();
         public Prefs() {
              p = Preferences.userNodeForPackage(getClass());
              g = new GUI();
         public void storePrefs() {
              for (int i = 0; i < g.symptoms.length; i++) {
                   p.putBoolean("symptoms", g.symptoms.isSelected());
         public void retrievePrefs() {
              for (int t = 0; t < g.symptoms.length; t++) {
                   p.getBoolean("symptoms", g.symptoms[t].isSelected());
    symptoms is the array of checkboxes in the GUI class. Not sure where I am going wrong here. I can do it with strings from textfields etc but this is proving to be an annoyance. :(
    Thanks in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Actually, I have a better example, see below
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    import java.util.prefs.*;
    public class PreferencesTest {
        private Preferences prefs;
        public static final String PREF_OPTION = "SELECTED_MENU_ITEM";
        public void createGui() {
            prefs = Preferences.userNodeForPackage(this.getClass());
            JMenuItem exitAndCloseMenuItem = new JMenuItem("Exit");
            exitAndCloseMenuItem.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e) {
                    System.exit(0);
            JMenu fileMenu = new JMenu("File");
            fileMenu.add(exitAndCloseMenuItem);
            JCheckBoxMenuItem[] preferenceItems = {
                new JCheckBoxMenuItem("pref 1"),
                new JCheckBoxMenuItem("pref 2"),
                new JCheckBoxMenuItem("pref 3"),
                new JCheckBoxMenuItem("pref 4")};
            int selectedMenuItem = prefs.getInt(PREF_OPTION, 0);
            preferenceItems[selectedMenuItem].setSelected(true);
            ButtonGroup preferencesGroup = new ButtonGroup();
            JMenu preferenceMenu = new JMenu("Preferences");
            for(int i = 0;i<preferenceItems.length;i++){
                preferenceItems.setActionCommand(Integer.toString(i));
    preferenceItems[i].addActionListener(new menuItemActionListener());
    preferencesGroup.add(preferenceItems[i]);
    preferenceMenu.add(preferenceItems[i]);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(preferenceMenu);
    JFrame f = new JFrame("Prefernce Test");
    f.setJMenuBar(menuBar);
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    public static void main(String[] args){
    new PreferencesTest().createGui();
    class menuItemActionListener implements ActionListener{
    public void actionPerformed(ActionEvent e) {
    JCheckBoxMenuItem jcbm = (JCheckBoxMenuItem)e.getSource();
    prefs.put(PREF_OPTION, jcbm.getActionCommand());

  • Storing an array permanently

    Hi,
    Is there a way of storing an array permanently, so that it stays saved somewhere in a file or something? I need to create an application that stores this array and reads the values from it, without having to re-create the array everytime I run the application.
    Thanks for any help.

    Serialization is flakey (can have many problems when JDK or class is updated), wasteful of space, and IMO should be the implementation of last resort.
    Here's a code snippet of what I would do:
    public void saveArray(Object[] array, File f) throws IOException {
      PrintWriter writer = new PrintWriter(new FileWriter(file));
      for (int i = 0; i < array.length; i++)
         writer.println(array.toString);
    writer.close();

  • Storing an array into the database using jdbc

    Hi,
    i�ve got a problem storing an array into a database. I want to store objects consisting of several attributes. One of these attributes is an array containing several int values. I don�t know exactly what is the best way to store these objects into a database. I have created two tables connected by a one to many relationship of which one stores the array values and the other table stores the object containing the array. Is that ok or should I use another way. It�s the first time I�m trying to store objects containing arrays into a database so I�m very uncertain in which way this should be done.
    Thanks in advance for any tips

    1. You should use blob or longvarbianry type colum to stor that array.
    2. All object in that array should be Serializable.
    3. Constuct a PreparedStatement object
    4. Convert array to byte[] object
    ByteArrayOutputStream baos=null;
    ObjectOutputStream objectOutputStream=null;
    baos = new ByteArrayOutputStream(bufferSize);
    objectOutputStream = new ObjectOutputStream(baos);
    objectOutputStream.writeObject(array);
    objectOutputStream.flush();
    baos.flush();
    byte[] value=baos.toByteArray();
    5. Now you can use PreparedStatement.setBytes function to insert byte[] value.

  • Can I use an OLE DB Command Task to call a parameterized stored procedure, perform some data editing and pass variables back to the SSIS for handling?

    I am using a Data Flow and an OLE DB Source to read my staged 3rd party external data. I need to do various Lookups to try and determine if I can find the external person in our database...by SSN...By Name and DOB...etc...
    Now I need to do some more data verification based on the Lookup that is successful. Can I do those data edits against our SQL server application database by utilizing an OLE DB Command? Using a Stored Procedure or can I sue straight SQL to perform my edit
    against every staging row by using a parameter driven query? I'm thinking a Stored Procedure is the way to go here since I have multiple edits against the database. Can I pass back the result of those edits via a variable and then continue my SSIS Data Flow
    by analyzing the result of my Stored Procedure? And how would I do that.
    I am new to the SSIS game here so please be kind and as explicit as possible. If you know of any good web sites that walk through how to perform SQL server database edits against external data in SSIS or even a YouTube, please let me know.
    Thanks!

    Thanks for that...but can I do multiple edits in my Stored Procedure Vaibhav and pass back something that I can then utilize in my SSIS? For example...
    One and Only one Member Span...so I'd be doing a SELECT COUNT(*) based on my match criteria or handle the count accordingly in my Stored Procedure and passing something back via the OLE DB Command and handling it appropriately in SSIS
    Are there "Diabetes" claims...again probably by analyzing a SELECT COUNT(*)
    Am I expecting too much from the SSIS...should I be doing all of this in a Stored Procedure? I was hoping to use the SSIS GUI for everything but maybe that's just not possible. Rather use the Stored Procedure to analyze my stged data, edit accordingly, do
    data stores accordingly...especially the data anomalies...and then use the SSIS to control navigation
    Your thoughts........
    Could you maybe clarify the difference between an OLE DB Command on the Data Flow and the Execute SQL Task on the Control Flow...
    You can get return values from oledb comand if you want to pipeline.
    see this link for more details
    http://josef-richberg.squarespace.com/journal/2011/6/30/ssis-oledb-command-and-procedure-output-params.html
    The procedure should have an output parameter defined for that
    I belive if you've flexibility of using stored procedure you may be better off doing this in execute sql task in control flow. Calling sp in data flow will cause it to execute sp once for each row in dataset whereas in controlflow it will go for set based
    processing
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • LabVIEW DLL 2D Array output deallocati​on

    Hey everyone,
    I am using a custom built DLL made with LabVIEW.  One of the functions outputs a 2D array of data by "handle".  I can catch the 2D array from the function just fine from within my C program, however I have a question about deallocating the memory allocated by the LabVIEW DLL for the 2D array.
    I call the DLL function repeatedly in a loop and as this occurs the RAM used on my machine continues to increase until it is full or I exit the program.  There are no other dynamically allocated peices of data within the C program that could be causing this.
    The question is, can I call free() on the 2D array handle safely?  Is this the correct way to deallocate the 2D arrays passed out of LabVIEW DLL functions?  One dimension of the 2D array is always the same size, but the other dimension varies per call.
    Here is an example (I have renamed function calls and library headers due to security reasons):
    #include "DLLHeader.h"
    int main(void)
        ResponseArrayHdl myArray = NULL;
        DLL_FUNC_InitializeLibrary();
        DLL_FUNC_ConfigurePortWithDefaults("COM3");
        DLL_FUNC_StartAutoSend(9999999);
        while(DLL_FUNC_IsTransmitting())
            DLL_FUNC_GetAllAvailableResponseMessagesByHndl(&my​Array);      // gets the 2D array
            // do something with array data here!
            free(myArray);   // is this the appropriate way to clean up the array?
            Delay(0.05);
        DLL_FUNC_GetAllAvailableResponseMessagesByHndl(&my​Array);      // gets the 2D array
        // do something with array data here!
        free(myArray);   // is this the appropriate way to clean up the array?
        DLL_FUNC_ShutdownLibrary();
        return 0;
    from DLLHeader.h:
    typedef struct {
        } ResponseMessage;      // created by the LabVIEW DLL build process
    typedef struct {
        long dimSize;
        ResponseMessage Responses[1];
        } ResponseArray;
    typedef ResponseArray **ResponseArrayHdl;   // created by the LabVIEW DLL build process
    I want to make sure this is an appropriate technique to deallocate that memory, and if not, what is the appropriate way?  I am using LabVIEW 7.1 if that matters.  The C program is just ANSI C and can be compiled with any ANSI C compliant compiler.
    Thanks!
    ~ Jeramy
    CLA, CCVID, Certified Instructor

    Tunde A wrote:
    A relevant function that will be applicable in this case (to free the memory) is the "AZDisposeHandle or DSDisposeHandle". For more information on this function and other memory management functions, checkout the " Using External Code in LabVIEW" reference manual, chapter 6 (Function Description), Memory Management Functions.
    Tunde
    One specific extra info. All variable sized LabVIEW data that can be accessed by the diagram or are passed as native DLL function parameters use always DS handles, except the paths which are stored as AZ handles (But for paths you should use the specific FDisposePath function instead).
    So in your case you would call DSDisposeHandle on the handle returned by the DLL. But if the array itself is of variable sized contents (strings, arrays, paths) you will have to first go through the entire array and dispose its internal handles before disposing the main array too.
    Rolf Kalbermatter
    Message Edited by rolfk on 01-10-2007 10:43 PM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • User to enter values and stored as array

    Hi,
    I have some problem with my labs that I would like to clear by doubt.
    I need a user to keyed in a list of age so to calculate the average age. The values entered is stored in into an Array (not arrayList) I have been using ArrayList rather than array. =(
    So I have used a bufferedReader to capture the input the user keyed in. unlike arraylist, I could not create an array without knowing the size of it.
    Also,
    My following code has some proble, when I run the program and enter 99 as the first value input. The system would terminate. However, when I enter other values than 99, the system would not terminate. Do point out my brainless mistake. Thanks alot.
      public static void main(String[] args) {
             // TODO, add your application code
            int num =0;
             int j = 0;
      boolean stop = false;
              int[] arr = new int[200];
               BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                  while(stop == false){
               try {
             num =  Integer.parseInt(br.readLine());
          } catch (IOException ioe) {}
          if(num == 99){
          stop = true;
        arr[j] = num;
        j++;
        }

    seah_ly wrote:
    I need a user to keyed in a list of age so to calculate the average age. The values entered is stored in into an Array (not arrayList) I have been using ArrayList rather than array. =(Yes you are correct in using an ArrayList, however if arrays are required you could mimic the actions of a growing ArrayList by using an array and initializing a new array with double the size of the old array and copying the old elements to the new array. Note this is exactly what an ArrayList does.
    My following code has some proble, when I run the program and enter 99 as the first value input. The system would terminate. However, when I enter other values than 99, the system would not terminate. Do point out my brainless mistake. Thanks alot.
    if(num == 99){
      stop = true;
    }What do you think this does to the while loop?
    Mel

  • Can't create float array with a variable name as size parameter?

    Hi,
    When trying to compile code that users a variable in the array subscript to set the size, CC gives the following error:
    Error: An integer constant expression is required within the array subscript operator.
    1 Error(s) detected.The code is as follows:
    int main()
    //blah blah
    const int arrSize = numberVariables;
        float tempArr[arrSize];
    //blah blah
    }Output from CC -V:
    unknown% CC -V
    CC: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25Output from uname -a:
    unknown% uname -a
    SunOS unknown 5.10 Generic_137138-09 i86pc i386 i86pcAny ideas on why CC is giving that error?
    ~Slow
    Edited by: SlowToady on Nov 15, 2008 8:28 PM
    Edited by: SlowToady on Nov 15, 2008 8:36 PM

    Marc_Glisse wrote:
    Last time I checked, I did not see VLAs in the draft of the next C++ standard, which I believe is now feature complete. So either I missed it (quite possible) or VLAs were considered a bad idea (for C as well many people consider alloca and VLA bad ideas). It is however a very reasonable extension to have (care to file a RFE?).The following code performs like this on an IBM x366 with 4 single-core 3.16 GHz Xeons, running OpenSolaris build 96:
    -bash-3.2$ ./thrtest
    malloc() took 440895924 ns
    alloca() took 2122522 ns
    -bash-3.2$Using alloca is two hundred times faster.
    Two hundred times faster.
    Think about that next time some pedant says alloca "sucks".
    Try for yourself. Here's the code:
    #include <stdlib.h>
    #include <pthread.h>
    #include <alloca.h>
    #include <strings.h>
    #include <stdio.h>
    #define NUM_THREADS 8
    #define ITERS 10000
    #define BYTES 1024
    typedef void ( *mem_func_t )( void );
    void alloca_iter()
        char *ptr;
        ptr = ( char * ) alloca( BYTES );
        memset( ptr, 0, BYTES );
        return;
    void malloc_iter()
        char *ptr;
        ptr = ( char * ) malloc( BYTES );
        memset( ptr, 0, BYTES );
        free( ptr );
        return;
    void *thread_proc( void *arg )
        mem_func_t mem_iter;
        mem_iter = ( mem_func_t ) arg;
        for ( int ii = 0; ii < ITERS; ii++ )
            mem_iter();
        return( NULL );
    int main( int argc, char **argv )
        pthread_t tids[ NUM_THREADS ];
        void *results[ NUM_THREADS ];
        hrtime_t start;
        hrtime_t end;
        int ii;
        start = gethrtime();
        for ( ii = 0; ii < NUM_THREADS; ii++ )
            pthread_create( &tids[ ii ], NULL, thread_proc, malloc_iter );
        for ( ii = 0; ii < NUM_THREADS; ii++ )
            pthread_join( tids[ ii ], &results[ ii ] );
        end = gethrtime();
        printf( "malloc() took %ld ns\n", end - start );
        start = gethrtime();
        for ( ii = 0; ii < NUM_THREADS; ii++ )
            pthread_create( &tids[ ii ], NULL, thread_proc, alloca_iter );
        for ( ii = 0; ii < NUM_THREADS; ii++ )
            pthread_join( tids[ ii ], &results[ ii ] );
        end = gethrtime();
        printf( "alloca() took %ld ns\n", end - start );
        return( 0 );
    }

  • PL/SQL array bind output variable

    I've been trying to learn how to pass an array to an pl/sql script. Getting the data into the db seems to be working fine, but I would like to know if there was a problem inserting the data. More specifically, I would like to know THE SPECIFIC ROW that caused the problem.
    pl/sql code:
    create or replace procedure pp (
              v_out      out number,
              v_listtype in repair_codes.listtype%type,
    v_repaircode in repair_codes.repaircode%type
    is
    begin
    insert into repair_codes (listtype, repaircode) values (v_listtype,v_repaircode);
         v_out:=1;
    commit;
         --just setting up test variable for now     
    end;
    vb.code:
    Dim cmd As New OracleCommand("pp", dbConn)
    cmd.CommandType = CommandType.StoredProcedure
    cmd.ArrayBindCount = 3
    Dim al(2) As String
    Dim ar(2) As String
    al(0) = "JOE1"
    al(1) = "JOE2"
    al(2) = "JOE3"
    ar(0) = "TEST1"
    ar(1) = "TEST2"
    ar(2) = "TEST3456789"
    Dim out As New OracleParameter("v_out", OracleDbType.Varchar2, 20)
    out.Direction = ParameterDirection.Output
    cmd.Parameters.Add(out)
    Dim listtype As New OracleParameter("v_listtype", OracleDbType.Varchar2)
    listtype.Value = al
    cmd.Parameters.Add(listtype)
    Dim repaircode As New OracleParameter("v_repaircode", OracleDbType.Varchar2)
    repaircode.Value = ar
    cmd.Parameters.Add(repaircode)
    dbConn.Open()
    Try
    cmd.ExecuteNonQuery()
    Catch ex As OracleException ' catches only Oracle errors
    ex = ex
    Select Case ex.Number
    Case 1
    MessageBox.Show("Error attempting to insert duplicate data.")
    Case 12545
    MessageBox.Show("The database is unavailable.")
    Case Else
    MessageBox.Show("Database error: " & ex.Message.ToString())
    Dim wha = ex.Errors(0).ArrayBindIndex 'always '0'
    End Select
    Finally
    dbConn.Close()
    End Try
    error:
    OracleParameter.ArrayBindSize is invalid
    Code above will work if I remove everything about the 'output' variable
    To test I would like to put in data for a column that is too large, have all other rows inserted, but return the row that had bad data. Thanks for any thoughts on this-

    I have a similar issue, i.e. the pl/sql table type as out parameter is causing probleml in one API related to Oracle Applications. I have singled this problem out by creating wrappers and testing them against BPEL process. Now as soon as I put an out parameter with pl/sql table in my wrapper, I start getting errors. Why the invoke even care about what is in output while calling the API? How can I get rid of it. I am not able to pin point where exactly you made the changes. Could you please share some more info or possibly share the BAD and GOOD code.
    We will probably get away with this by creating just a wrapper that would have NO out parameter as PL/SQL table as I don't think we need it anyway.
    Still want to know what is the issue here as we would like to avoid any custom wrapper creation?
    Shobhit
    Message was edited by:
    Shobhit.Kapila

  • Retrieve LV stored 2D-Array via MySQL C-API

     Hello everybody!
    I am not quite sure, if this is the right place for my question, but I'll just give it try.
    I have a LabVIEW Vi which performs Data Acquistion-Tasks. The Data is stored in a MySQL-Database using the Labview Database Connectivity Toolset. One part of the stored data is a 2D-Double-Array. For storage in MySQL It is automatically converted to Binary Data and the stored in a MySQL Blob-Field.
    Unfortunately, the software to process the data is written in C++. It was fairly easy to establish the communication between my c++ application and MySQL via the MySQL C-API. But now i'm struggling to retrieve the Binary-Data from the Database and reconvert it into a C++ Double Array, as am not very experienced with C++.
    Has anyone done something similar before?

    Hello
    I am happy to hear that your LabVIEW application and data storage with the LabVIEW Database Connectivity Toolkit works.
    Unfortunately is this the wrong platform to ask about C++. There are many other open platforms discussing C questions. I’d propose you to ask your question there.
    Best Regards
     Daniela Biberstein
    NI Switzerland

  • Vector (good for storing) and arrays(good for numerical sums, multiplying)

    Hi guys, I am trying to use vectors because I need a variable lenght and store 2D arrays in one coordenate of a vector. That is why I am using vector instead arrays. I can turn the type of variable using "Integer" (instead of "int" as arrays), "Double" (instead of "double") and so on. The problem is that it doesn't allow me to operate, it is very good for storing, but I need to be able to operate, multiplying, sum, etc the elements there are in the coordenates. And I think it is not possible.
    What u think about it? I can only store stuff ion a vector, I cannot operate. Besides I cant turn a data from "Double" to "double", I can either use arrays OR vectors, but not both of them at the same time.
    You think i am wrong?, because I mean in that case, Java is not very useful to do this numerical problem.
    Thanks.
    This is only a class of the program I am doing.
    import java.util.*;
    class SolveDomain {
         int newton_iter = 0, m = 0, work_count = 0;
         double t = 0, dx, dy, dt, start_t=0;
         double[][] v;
    Details obDetails = new Details();
         public double[][] solveDomainMethod(Double vAxn, Double vAyn, Double vBxn, Double vByn, Integer nxn, Integer nyn, double dt, Double error1n, Double error2n, double end_tn, int stepsn, Integer kcn, Double u_n[][], Double v_n[][], Double bc1, Double bc2, Double bc3, Double bc4, double u[][]) {       
         double dx2, dy2, err = 1000000;
         v = new double[nxn+1][nyn+1];
         DoublevAxn, Double vAyn, Double vBxn, Double vByn, Integer nxn, Integer nyn, double dt, Double error1n, Double error2n, double end_tn, int stepsn, Integer kcn, double u_n[][], double v_n[][], Double bc1, Double bc2, Double bc3, Double bc4;
    double k[][] = new double [nxn+1][nyn+1]; double kp[][] = new double [nxn+1][nyn+1];
    double kpp[][] = new double [nxn+1][nyn+1]; double dudx[][] = new double [nxn+1][nyn+1];
    double dudy[][] = new double [nxn+1][nyn+1]; double d2udx2[][] = new double [nxn+1][nyn+1];
    double d2udy2[][] = new double [nxn+1][nyn+1]; double dudt[][] = new double [nxn+1][nyn+1];
    double a[][] = new double [nxn+1][nyn+1]; double b[][] = new double [nxn+1][nyn+1];
    double c[][] = new double [nxn+1][nyn+1]; double d[][] = new double [nxn+1][nyn+1];
    double F[][] = new double [nxn+1][nyn+1]; double A[][] = new double [nxn+1][nyn+1];
    double B[][] = new double [nxn+1][nyn+1]; double C[][] = new double [nxn+1][nyn+1];
    double D[][] = new double [nxn+1][nyn+1]; double E[][] = new double [nxn+1][nyn+1];
    double s[][] = new double[nxn+1][nyn+1];
              KDerivatives1 obK1 = new KDerivatives1();
              KDerivatives2 obK2 = new KDerivatives2();
    UDerivatives obU = new UDerivatives();
              CalcPdeCoefficients obPde = new CalcPdeCoefficients();
              CalcFdCoefficients obFd = new CalcFdCoefficients();
              Gs obGs = new Gs();
    dx = obDetails.seg(vBxn, vAxn, nxn);
    dy = obDetails.seg(vByn, vAyn, nyn);
    dx2 = dx*dx;
    dy2 = dy*dy;
    if (bc1 != -999999999) obDetails.initialiceBCDomainL(dx, dy, vAxn, vAyn, bc1, u);
    if (bc2 != -999999999) obDetails.initialiceBCDomainU(dx, dy, vAxn, vAyn, bc2, u);
    if (bc3 != -999999999) obDetails.initialiceBCDomainR(dx, dy, vAxn, vAyn, bc3, u);
    if (bc4 != -999999999) obDetails.initialiceBCDomainD(dx, dy, vAxn, vAyn, bc4, u);
    obDetails.source(dx, dy, vAxn, vAyn, s);
    do {
    ++ newton_iter;
    if (kcn == 1) { 
              obK1.calc_k(u, k);
         obK1.calc_kp(u, kp);
         obK1.calc_kpp(u, kpp);
              } else {
                   obK2.calc_k(u, k);
              obK2.calc_kp(u, kp);
              obK2.calc_kpp(u, kpp);
                   obU.calc_dudx(u, dx, dudx);
              obU.calc_dudy(u, dy, dudy);
                   obU.calc_d2udx2(u, dx2, d2udx2);
                   obU.calc_d2udy2(u, dy2, d2udy2);
              obU.calc_dudt(u, u_n, dt, dudt);
              obPde.calcPdeCoefficientsa(k, a);
              obPde.calcPdeCoefficientsb(kp, dudx, b);
              obPde.calcPdeCoefficientsc(kp, dudy, c);
              obPde.calcPdeCoefficientsd(kp, kpp, dudx, dudy, d2udx2, d2udy2, d);
              obPde.calcPdeCoefficientsF(k, kp, dudx, dudy, d2udx2, d2udy2, dudt, s, F);
              obFd.calcFdCoefficientsA(a, b, dx, dx2, A);
              obFd.calcFdCoefficientsB(a, b, dx, dx2, B);
              obFd.calcFdCoefficientsC(a, c, dy, dy2, C);
              obFd.calcFdCoefficientsD(a, c, dy, dy2, D);
              obFd.calcFdCoefficientsE(a, d, dx2, dy2, dt, E);
              obGs.gsMethod(v_n, A, B, C, D, E, F, dt, error2n, v);
              m = m + obGs.iter;
              for (int i=1; i < u.length - 1;i++ ) {
                   for (int j=1; j < u[0].length - 1 ;j++ ) {
         u[i][j] = u[i][j] + v[i][j];
    err = 0;
              for (int i=0; i < u.length ;i++ ) {
                   for (int j=0; j < u[0].length ;j++ ) {
                   err = err + Math.pow(v[i][j],2);
              err = Math.sqrt(err);
    while (err > error1n);
         return u;           
    public double[][] rectangleDomainF (Vector vAxvector, Vector vAyvector, Vector vBxvector, Vector vByvector, Vector nxvector, Vector nyvector, Vector error1vector, Vector error2vector, double end_t, int steps, Vector kcvector, double numberdomains, Vector bc1vector, Vector bc2vector, Vector bc3vector, Vector bc4vector) {
                   double u[][] = new double[u.length][u[0].length];
                   double dt = obDetails.seg(end_t, start_t, steps);
                   Vector uvector = new Vector();
                   Vector vvector = new Vector();
         do
    ++work_count;
              t = work_count * dt;
    for (int k = 0; k < numberdomains ; k++) {
         solveDomainMethod((Double)vAxvector.elementAt(k), (Double)vAyvector.elementAt(k), (Double)vBxvector.elementAt(k), (Double)vByvector.elementAt(k), (Integer)nxvector.elementAt(k), (Integer)nyvector.elementAt(k), dt, (Double)error1vector.elementAt(k), (Double)error2vector.elementAt(k), end_t, steps, (Integer)kcvector.elementAt(k), (Double [][]) uvector.elementAt(k), (Double [][]) vvector.elementAt(k), (Double)bc1vector.elementAt(k), (Double)bc2vector.elementAt(k), (Double)bc3vector.elementAt(k), (Double)bc4vector.elementAt(k), u);
                                                           uvector.insertElementAt(u, k);
              vvector.insertElementAt(v, k);
    while (t < end_t);
    return u;

    The only way to, for instance, multiply a Double object by another Double object is to convert them back to primitives, multiply them, and create a new Double instance:
    public Double multiply(Double lhs, Double rhs) {
       return new Double( lhs.doubleValue() * rhs.doubleValue() );
    }This is just an overhead that you have to accept if you want to use collections with primitive type data.
    Coming soon in 1.5 (which is in Beta now and available for download in the usual places) a new feature called auto-boxing will do a lot of this automatically for you. You need to be aware that it's doing exactly the same operations with the same performance overhead; but it does save a lot of typing.
    Thus in 1.5 the above becomes:
    public Double multiply(Double lhs, Double rhs) {
       // Under the hood this is IDENTICAL to the above example
       return lhs * rhs;
    }Now, addressing your post directly:
    Besides I cant turn a data from "Double" to "double"
    Yes you can, as in the first example, the doubleValue() method converts a Double object to a double primitive.
    Java is not very useful to do this numerical problem.
    If you need math performance, you need to use primitives, yes. Yes, that will preclude the use of collections.
    Dave.

  • Storing current slide in a variable, then using the variable to get back to that slide (Captivate 6)

    I'm thinking there must be some info on this somewhere, because it's something people must want to do, but I haven't been able to find an answer.
    I would like to set something up so that when a user clicks on a button, it will take them to a certain slide. But I want the current slide stored in a variable. And then, when they are ready to go back, there will be a return button, but it should check to see where they came from and then return them to that specific slide. Basically, a "return to last slide visited" type of advanced action. I can't use the "return to last slide" option because the slide they are taken to when they first click the button has multiple slides, so the "return to last slide" option would not take them to the last slide they were on before visiting this page. I tried to store this in a variable on a button click by assigning a variable with CpInfoCurrentSlide, and then jumping to a slide. But, I'm not sure how I would then use that info to return to this slide.

    Captivate Advanced Actions don't actually provide an easy way to do this.  It's another area we really need to address in forthcoming versions.
    You need to use an On Enter Slide event to store the value of the cpInfoCurrentSlide system variable in a user variable.
    Then you need to create another advanced action that can be triggered by your later button.  Somewhat counterintuitively, you need to use an Expression action (rather than an Assign action) to assign the value captured in your user variable to cpCmndGotoSlide.  But that's not all.  Due to the way Captivate's slide indexes work, you'll need to deduct one from the value of your user variable before assigning it to cpCmndGotoSlide.
    Then, unless you want the slide timeline to pause, you need to add a Continue action.
    The final action looks a bit like this:

Maybe you are looking for

  • Create new repository in db 11.1.0.7.3

    Hi I am trying to use RepManager from a Grid Control v10.2.0.5 (fully patched) home to create a new Grid Control repository within a Database v11.1.0.7.3 (fully patched) and it falls over stating the following error on screen: Repository Creation fai

  • Zen Micro A/C power cord opti

    Hi All, My Micro recharges just fine when plugged into the USB of my computer with Creative software. However, it will not charge using USB on other computers. Also, I tried plugging in my Blackberry charger (output 5V,?0.7A)?to the USB port. The Mic

  • Firefox issue  h:datatable give more space between columns

    Hi In our application we are displaying table by using <h:datatable>,it was working fine in IE but when i used an firefox it gives more space between one row of data and next data row.. my code is like this <a:outputPanel id="searchResults">      <h:

  • When I attach my Samsung Galaxy Note 3 Sview case my phone slows down.  Has any one experienced this?

    After getting an S-view case for my Note 3, I noticed many of my apps slowing down during use.  When I remove the case, the phone acts normally.  Also, when I go to the sview settings to add weather, it prompts me that settings has stopped working an

  • Yosemite and Canon A630 camera

    I have a Canon A630 camera which I have been using successfully on a Windows machine. I attached it to a new MacBook Pro running Yosemite and it does not recognize that the camera is attached. Do I need software from Canon or should Yosemite recogniz