Combining formula node and arrays for calculatio​n

Hello all!
I have two arrays containing values defined by me. Each value of respective column and row index shall be used in a formula to calculate the new value for the respective column and row, to build a new array for further use. This shall be done several times during a simulation with variable function parameters.
I am aware that I should probably use a for loop for this calculation, but I am curious to how I should build such a procedure.
Any ideas?

Hi Euler123,
Let's say that you have an array of fix size and with values in it. Then you'll need to use auto indexing at the beginning of each for loop input tunnel (usually it is by default for for loops) as shown below:
In the first iteration of the other for loop, it will take the first row values [1, 2, 3] and pass it to the inner for loop (unless you want to extract the values for each column, transpose that 2D array before connecting it to the outer for loop). In the inner for loop, it will execute 3 times and each iteration it will extract each element from the array obtained from the outer for loop. 
To build the new array, it's just the opposite. Pass the element out from the for loop and instead of getting a last value tunnel, you'll get an auto indexing tunnel (default for for loops).
Anyways, you'll need to get some basic understanding on LabVIEW first. Here's some tutorials to aid you on understanding For Loops.
http://www.youtube.com/watch?v=ziOnPNJgeVg
Here's some additional notes which might help you:
http://zone.ni.com/reference/en-XX/help/371361J-01​/lvhowto/auto_indexing_1/
http://zone.ni.com/reference/en-XX/help/371361H-01​/lvhowto/auto_indexing_1/
http://zone.ni.com/reference/en-XX/help/371361G-01​/lvhowto/auto_indexing_1/
Play around with For Loops and use something to slow the execution down like Highlight Execution which allows you to see what is going on. Else, take up some LabVIEW courses
Warmest regards,
Lennard.C
Learning new things everyday...

Similar Messages

  • Formula nodes and hex values: strange behavior?

    Hi all,
    I am having problems using hex values in a formula node. It appears that the hex values are converted to decimal and then assigned to the variable. For example, if I initialize an int8 in a formula node to 0xFE (should be -2), I get 127 (the highest positive value an int8 can have). In order to get -2, I must initialize the variable to -0x02. However, if I initialize the variable to -2 decimal and view it in a indicator in hex, it displays the correct 0xFE. Is this typical behaviour? I didn't think negative hex values were used and I can't find it documented anywhere. Here is a VI that shows the "problem".
    Thanks!
    Attachments:
    Formula Node Example.vi ‏7 KB
    Formula Node Example.png ‏31 KB

    Hi brett,
    int8 test = 0xFE
    You defined a variable to be of type I8, but then you want to assign a value out of range of that datatype. LabVIEW will coerce the value to fit the datatype resulting in 0x7F stored in test.
    int16 test2 = test
    Now you copy the value stored in test over to test2. Why do you even expect a value of 0xFE here? In the line before you stored 0x7F in test, so test2 will also have the value 0x7F!
    int8 test3 = -0x02
    This was explained before…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Lack of texts in hierarchy nodes and leafs for 0ORGUNIT

    Hello experts!
    We have the BCT hierarchy 0ORGUNIT in BW exporting his time-dependent structure from R/3. Now, for some leafes and some nodes above the leaf we have no texts just see the key.
    Has someone an idea what the problem could be? In R/3 we have the text and in master data of 0ORGUNIT we also have the text within the right time period...
    Thanks for help!
    Best reagards,
    Peter

    I'm not sure I understand what you are suggesting. Here is the data we have:
    Hierarchy             Key Figure
    - CC 0001 (node)      30.56
      CC 0001 (leaf)          6.45
      - CC 0002 (node)       24.11
           CC 0002 (leaf)     6.45
           CC 0003 (leaf)     5.72
           CC 0004 (leaf)     7.47
           CC 0005 (leaf)     4.47
    We want the value 6.45 to show up next to the CC 0002 hierarchy node, since that is the value for that cc. And we want the 6.45 to show up against the cc 0001 node rather than adding everything beneath it. What you suggested below - is that a display option in the query, or where do I do it?
    Thanks.

  • How to Search and Array for multiple occurrences of a value

    Hi,
    I am trying to search an array of doubles for a number and report the index location(s) of a number. I.e. -allow for repetition. Search and report all index[i] where the number is contained in the array. For example I have
    double[] myInputArray = new double[5];
    double[] myInputArray = { 1, 2, 3, 3, 5 }I know how to search through the array ONCE and return the first occurrence of a number:
    public double GetIndexOf(double Number) {
        for (int i=0; i<myInputArray.length; i++) {
             if (myInputArray[i] == Number){
                  return(i);
        return(-1);
      }How do I expand this code to report multiple index[i] locations if the number reoccurs in the array like the number 3 does in my example array above?

    The way the Java libraries do this type of operation (String.indexOf(), etc) is to specify the starting index along with what you want to find.
    Changing your example slightly (notice how I fixed your naming and more importantly, your return type):
    public int indexOf(double num) {
       return indexOf(num, 0);
    public int indexOf(double num, int fromIndex) {
        for (int i=fromIndex; i<myInputArray.length; i++) {
             if (myInputArray[i] == num){
                  return(i);
        return(-1);
    //usage to get all indices:
    for ( int index = -1; (index = indexOf(num, index+1)) != -1; ) {
       System.out.println(index);
    }Note that due to how floating point numbers work, you may find doing this on doubles (or any other operation that uses == with double arguments) to give you unexpected results.

  • 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 create a slide combining an FLV and jpeg for use in PP?

    I am using the CS4 Master Collection. I want to integrate slides into my DVD curriculum project. I would like to use the flv as the background, put a slightly smaller jpeg (or other graphic) translucent tinted panel on top of it, and then my text. Can it be done?

    What I have is a nice FLV from istockphoto that I want to use as sort of a bottom layer, put a static tinted translucent layer on top of it, and finally the text layer. Then put it in PP. It would make a nice slide I think as I move from the talking head to various graphics. Is there a Title template perhaps that is translucent that would show the FLV underneath and I could easily add the text?
    Maybe this question should be posed in the Flash or Photoshop forum?

  • HELP: Run-time array dimension in LabVIEW formula node

    I need to dimension an array at run time within a formula node as follows:
    int32 i,N;
    N = sizeOfDim(inputArray,0);
    float64 outputArray[N];
    for (i = 0; i outputArray[i] = myfunction(inputArray[i]);
    However, LabVIEW complains "Formula Node: index list expected". On the
    other hand, if I say
    float64 outputArray[1000];
    LabVIEW is perfectly happy. But that's not what I need to do! Is there
    an alternative
    way of accomplishing my goal?
    BTW, I've tried calculating N outside the formula node and then
    presenting it as
    an input with the same results. I've got a bad feeling that run time
    array dimensioning
    just isn't allowed.
    TIA,
    Hugh

    Can't you just use the Initialize Array function outside the formula node and pass that instead?

  • Array output from formula node

    How to get an array output from the formula node.I am trying to use a for loop inside the formula node and want an array output.

    You cannot place a For or While Loop inside the formula node.
    Here is what the Help Description says about the syntax inside the Formula Node:
    Formula Node
    Evaluates mathematical formulas and expressions similar to C on the block diagram. The following built-in functions are allowed in formulas: abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, cot, csc, exp, expm1, floor, getexp, getman, int, intrz, ln, lnp1, log, log2, max, min, mod, pow, rand, rem, sec, sign, sin, sinc, sinh, sizeOfDim, sqrt, tan, tanh. There are some differences between the parser in the Mathematics VIs and the Formula Node.
     Place on the block diagram
     Find on the Functions palette
    Refer to Creating Formula Nodes and Formula Node Syntax for more information about the Formula Node and the Formula Node syntax.
    Note  The Formula Node accepts only the period (.) as a decimal separator. The node does not recognize localized decimal separators.
    <SCRIPT type=text/javascript>if (typeof(writeVarRefs)=="function"){writeVarRefs("763");}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvrthelp763) != "undefined"){document.writeln(lvrthelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvfpga763) != "undefined"){document.writeln(lvfpga763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvemb763) != "undefined"){document.writeln(lvemb763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvpdahelp763) != "undefined"){document.writeln(lvpdahelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvtpchelp763) != "undefined"){document.writeln(lvtpchelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvblackfin763) != "undefined"){document.writeln(lvblackfin763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvdsp763) != "undefined"){document.writeln(lvdsp763)}</SCRIPT>
    Example
    Refer to the Create Function with Formula Node VI in the labview\examples\general\structs.llb for an example of using the Formula Node.

  • Array index problem in formula node

    dear friend
    I'm trying to use formula node to solve a problem because I make this program using c at the begining.
    It runs perfectly in turbo c, but somehow it doesn't work in the formula node.
    I try to debug my source code, and I find that the formula node seems can't read the true value in
    the array.
    Here is the code in the formula node.
    int32 i,j,k;
    for ( i = 0 ; i < sopa; i++ )
     j = 1;
     ep[i][0] = pa[i];
     ep[i][1] = np[ep[i][0]][0];
     while ( ep[i][j-1] != exit )
      for ( k = 0 ; k < sonp ; k++ )
        if ( np[ep[i][j-1]][k] != -1 && (pc[ep[i][j-1]][ep[i][j]] + pc[ep[i][j]][exit] >= pc[ep[i][j-1]][np[ep[i][j-1]][k]] + pc[np[ep[i][j-1]][k]][exit] ) && (pc[ep[i][j-1]][np[ep[i][j-1]][k]] == org[ep[i][j-1]][np[ep[i][j-1]][k]] ))
          ep[i][j] = np[ep[i][j-1]][k];
      j++;
    This is the part that I think the problem might be.
    if ( np[ep[i][j-1]][k] != -1 && (pc[ep[i][j-1]][ep[i][j]] + pc[ep[i][j]][exit] >= pc[ep[i][j-1]][np[ep[i][j-1]][k]] + pc[np[ep[i][j-1]][k]][exit] ) && (pc[ep[i][j-1]][np[ep[i][j-1]][k]] == org[ep[i][j-1]][np[ep[i][j-1]][k]] ))
     ep[i][j] = np[ep[i][j-1]][k];
    I state that "np[ep[i][j-1]][k] != -1" but I do get the value -1 in the array "ep".
    Could someone tell me why I get -1 in the array?
    I hope I can finally do it all by labview not using formula node,but array like "pc[ep[i][j-1]][np[ep[i][j-1]][k]] "
    seems very hard to wire in labview. Could someone give me some good advices of doing this?
    Thanks for your help

    altenbach 已寫:
    normanshi wrote:
     ep[i][0] = pa[i];                                          (A)
     ep[i][1] = np[ep[i][0]][0];                            (B)
    ...    if ( np[ep[i][j-1]][k] != -1 && ... )          (C)
          ep[i][j] = np[ep[i][j-1]][k];                       (D)
    I state that "np[ep[i][j-1]][k] != -1" but I do get the value -1 in the array "ep".
    Could someone tell me why I get -1 in the array?
    I hope I can finally do it all by labview not using formula node,but array like "pc[ep[i][j-1]][np[ep[i][j-1]][k]] "
    seems very hard to wire in labview. Could someone give me some good advices of doing this?
    There are many possible scenarios to get a -1 in the ep output. For example if the -1 gets already written in step (A) or (B) at a certain index, and that index does not get overwritten in step (D). You are indexing all over the place! Is there some bounds checking on the array contents? What are typical inputs and array sizes?
    I'm sure about that the -1 doesn't get already written in step (A) or (B) because ep[i][0] and ep[i][1] is fine. What really makes me confuse is that sometimes ep array has the value like this.
    That means it does overwritten some value in step (D). The -1 should never be written into it because I have already state that np[ep[i][j-1]][k] != -1. Somehow I still get -1,and this is really strange! I'm indexing all over the place becuase I can't figure out a better way to achieve my requirement.
    I think I should briefly tell you what I'm trying to do. In this program,I input some values which means the distance from one point to another. Then I use floyd's all pairs shortest-path algorithm to find all the shortest distance. Finally I want to find out the "shortest path". I mean like from point 4 to point 0,the shortest path might be like 4 -> 2 -> 1 -> 0, and what the formula node part do is trying to find out this "shortest path". Maybe you can give me some better advice of doing this, I have been thinking a better way to do it for about two months. I think I'm really not good at this.
    I try to do it all by labview ,but again I get a strange problem. This time the ep[i][j-1] doesn't get the correct value. In the first time i=0 j-1=0 ep[i][j-1] = 1,but the second time i = 0 j-1 = 1 ep[i][j-1] = 0. This makes the "ep[i][j-1]!=exit" get the incorrect boolean value. The ep[i][j-1] should be 2,not 0. I try to use highlight to find if I make any mistake, but I can't one.This is the input and I put the labview program in attached file (temp4.vi).
    Could you help me find out why this happened?
    Thanks for your help altenbach!
    由 normanshi 在 08-19-2006 10:06 PM 上編輯的訊息
    Attachments:
    temp4.vi ‏191 KB
    ep.jpg ‏10 KB
    input.jpg ‏9 KB

  • Formula Node: Array Size can be specified by wiring an input ?

    All
    I have a formula node where I have a module which operates on an array. I want to keep the size of the array generic. So I tried keeping the array size as an input N, and initialized the array as xdim[N]. It shows an error in my formula. what am i doing wrong ?
    Kudos always welcome for helpful posts

    I had exactly the same issue as Spartan00.
    Just for curiosity, I was comparing labview speed in initializing a gaussian array through both the normal graphic code and the formula node.
    The formula node proved to be MUCH, MUCH faster.
    float m = 0.5, s=0.5, x;
    int i;
    float y[1000000];
    for(i=0; i<1000000; i++) {
    x=i*1e-6;
    y[i]=exp(-pow((x-m),2)/(2*s));
    Unfortunately, I can't wire the array size as an input.
    (By the way, I simply enclosed the formula node in a for loop and let it run 10000 times to get the average execution time. I did the same for the equivalent graphical code and it turned out to be much slower).
    Has anybody ever tried to do the same?

  • In formula node how to use array outputs

    someone has talked about this. but it is still a problem to me.
    no matter how i declare the variable, the output terminal keeps a scalar.

    You should be able to declare it using:
    int32 VarName[x][y];
    That should make an array of 32bit integers.
    See one of my earlier posts here: http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000EE2C0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_TIER_0=0&USEARCHCONTEXT_TIER_S=0&USEARCHCONTEXT_QUESTION_0=array+formula+node&USEARCHCONTEXT_QUESTION_S=0
    Try copying the code that I posted into your formula node and see if you get an array out. Or try the example I attached with the same code in it.
    Let us know if you are still having trouble.
    Brian
    Attachments:
    ArrayFormulaNode.vi ‏23 KB

  • If-then statement in formula node

    **Note - The attached file shows the current block diagram.
    I have a formula node inside a for loop. Inside the formula node I am trying to program the if-then statement:
    If T1<2.0E-5 OR T1>5.5E-4 THEN GOTO 3
    U7=U7+V
    I have 4 items I need help with:
    (1) Is 'II' the correct operator for 'OR'?
    (2) Is 'goto' an acceptable operator within LabVIEW?
    (3) 'U7' is building a 1D array. How do I need to define it? Is it simply 'int U7'? Also, I will add an output value named 'U7' on the formula node wall with an indicator wired to it from outside the for loop.
    (4) Is my use of the equal sign appropriate or do I need to use '=='?
    Thanks for the help.
    Philip
    Attachments:
    if-then_in_FN.jpg ‏18 KB

    Thanks for the help. I went ahead and rewrote the program so I could omit the 'goto's. Another problem that I am having is that I want 2 statements for 1 assignment:
    if (T1>=.002004 && T1<=.002584)
    B1=U
    A1=V;
    I want to assign both B1 and A1 values when the above condition is true. I tried a comma between the U and A1 but it doesn't work as well. Should I define A1 and B1 separately? Or would this create problems?
    if (T1>=.002004 && T1<=.002584)
    B1=U;
    if (T1>=.002004 && T1<=.002584)
    A1=V;
    Thanks,
    Philip

  • Parenthesis in formula node

    I'm using the formula node and it appears that parenthesis don't work. Is this correct? What is the order of operations?
    The Formula Node Syntax page in the help is extremely brief and sparse, bordering on useless for anyone that doesn't already now what is going on. Is there a more thorough description of the Syntax anywhere?

    Thanks Dennis,
    The error is just an incorrect calculation.
    I put together a simple node and parenthesis did work. So something else must be amiss. I stripped down my VI and equation and made two formula nodes implementing the same equation with and without parenthesis. One gives an exponential decreasing curve, the other a constant array. Where is the error?
    Attachments:
    parenth_ex.vi ‏49 KB

  • Formula Node Calculation Issues

    I'm trying to make an array where the output is defined by the formula 25*(2^x) where x is the input variable, with integer iterations from 0 to 7.  To do this, I made an formula node and put it in a for loop.  Unfortunately the (^) symbol is not working right for the calculation.  I tested it simply with x^2 and this did not work, while having x*x returned the correct values.  Instead of outputting the correct values, it outputs seemingly random integers.  Anyone know why?  I am new to this software so I apologize if this this a common issue but I could not find help anywhere else.
    Solved!
    Go to Solution.

    If you use the numeric primitives rather than a formula node, craziness can be avoided (well, sometimes).
    Lynn

  • Real time processing in formula node

    hello all,
    I'm using LabVIEW for data acquisition of an analog signal.My sampling frequency is KHz. Now if I've to process these data's in formula node what type of variable I need to define in formula node.?
    For example,if I want to add add all the magnitudes of the samples and store the sum after each sample squired.How do I write the formula node?
    I'm an amateur in labVIEW. amateur guide.
    Thanks in advance.

    pramodantony wrote:
    Now if I've to process these data's in formula node what type of variable I need to define in formula node.?
    Who forces you to use the formula node? You simply need to process the data, the means should be irrelevant.
    Acquired data in LabVIEW can be of many forms (arrays, waveforms, dynamic data, etc.). Can you show us what you have?
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • Error 110 : INTERNAL" CLIENT_RECEIVE_FAILED

    Dear All, I am working on Java server proxy, In my scenario i am picking a file from sender File Adapter and in  Receiver side i am using java proxy (Inbound). But in SXMB_MONI , it give me the Error and Error no is :110 See the Detailed Error in Cal

  • Why can't u use adobe flash player with iPad II ?

    I use adobe flash player a good bit on my pc but I cannot download it from my ipadII why?

  • HT5312 how to reset my apple questions

    I need to reset my secerity questions how do I do that

  • Nested Repeat Regions

    I've got a page where I need nested repeat regions using the same data. Basically, list people who have donated money in groupings by level: $100-$199 Murray Nadia Thierry $200-$299 Dan Dan Patty I'm looking at Tom Muck's "Simulated Nested Region" ex

  • System Preferences keeps freezing

    Last night I attempted to change my desktop picture and thought I'd scroll through my own photos to choose one. When I got one in particular, it obviously changed the picture, then I couldn't change it back again. All I got was the spinning beach bal