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?

Similar Messages

  • Formula Node & Array Operations

    Hello,
    I'm trying to use the formula node to subtract the previous term from the current term (or the next term minus the current term), but I can't figure out how to
    use the array index to do it. 
    I've something along the lines of z_array[i+1]-z_array[i], but it only returns the difference of i+1-i....
    Please see the attached picture.
    Thank you,
    Solved!
    Go to Solution.
    Attachments:
    Formula node.JPG ‏23 KB

    That would be so easy to do in pure Lv code.
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Can I create array inside formula node

    I need to create and use array (multidimensional) inside a formula node. My LabVIEW version is 5.1.The input and output from/to formula node do not necessarily being array. Thank you.

    You need to declare a variable to be an array. To declare a multidimensional array of 32 bit intergers enter this:
    int32 VarName[x][y];
    Where x=1st dimension size (rows) and y=2nd dimension size (columns). You can then operate on this like you would an array in a text based language. Try the entering the example below in a formula node.
    int32 i;
    int32 y[5][2];
    for (i=0;i<5;i++)
    y[i][1] = x[i]+1;
    Where y is an output and x is an 1D array input.
    Hope this helps...
    Brian

  • String array into formula node

    Hello,
    I am taking data from SQL, I am getting multiple rows of data for many different devices. I would like to wire the data into a formula node so I can sepearate and sort via script. However, I am getting an error for "Polymorphic terminal cannot accept this data type". Is there a work around? Can I not wire in a string array to a formula node.
    /r
    Travo

    There are lots of basic string VIs that you can use to parse the string and separate out the individual fields. I would recommend "programming" your application using script nodes. Use the native language. LabVIEW is a fully functional and capable programming language.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • PV cell equation error in formula node

    Hi! I am currently building a PV system simulation in LabVIEW with maximum power point tracking, and I'm trying to make this VI work using the formula node but I can't run it due to an "array indexing problem". The VI is based on the LabVIEW's toolkit for IV characterization using the equation for the PV cell current. I added the XY graph to graph the current and voltage from the equation. I'm really new to LabVIEW, so any suggestion will be greatly appreciated. I  have attached the VI I'm building.
    Solved!
    Go to Solution.
    Attachments:
    eqn_based.vi ‏11 KB

    Hi spectre,
    the formula not cannot calc with arrays the way LabVIEW does:
    (Check for correct computation against given formula...)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Formula node, condition

    I want to use conditional expressions such as
    if () then
    statement
    else
    end if
    in the formula node, but there were error messages "unassigned output".
    I followed Ankita's suggestion to use
    if (x<5)
    y=4;
    z=8;
    else
    y=8;
    z=4;
    but there were same error messages(I tried "end if;" also.).
    Thanks.

    Which version of LabVIEW are you using? Any chance it is earlier than 6.0?
    If so, then Ankita's suggestions probably won't work, because there were major changes in Formula Node behavior. I recall that every variable introduced in pre-6.0 formula nodes had to be explicitly added as either an input terminal or an output terminal on the formula node. Furthermore, those older formula nodes used a different style for conditional syntax. It's all documented in the manuals or help documentation that shipped with your LabVIEW version, whatever that may be.
    More to the point, I suggest that you abandon the formula node for simple conditionals like this and just use a case statement. You can wire your x variable into a less-than node, then wire the output of that into a case statement selector. You can very often avoid formula nodes by using case statements or even the "Select" node on the Comparison palette.
    My two cents,
    John

  • Log10 used in a formula node

    I am trying to create a formula using log10(X) in a formula node.  I can enter log(X) with no errors, but when I enter log10(X) I get an error.  How do I use log10 in a formula node?  Is log(X) actually log10?
    Alan

    Hi Alan,
    by reading the context help of the formula node ("click for more help" ) I found: log(x) is base10, otherwise you may use ln(x) or log2(x).
    Message Edited by GerdW on 12-17-2008 08:26 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How do I determine array size in a formula node

    I am feeding an array into a formula node to perform an operation on. However the size of the array can be an arbitrary size. How can I determine its size to use for iterating through a for loop?
    I suppose that I could add another input that is fed with the array size from the array palate but I would like to know if it can be done inside the formula node itself.

    Your own advice is the only and best one.
    greetings from the Netherlands

  • Array output from formula node with input variable as array size

    Hi,
    I have created a formula node with an array output called al, but I get an error "you have connected a scalar type to an array with that type".
    I declare the output as follows..
    float64 al[len_as];
    where len_as is an scalar input to the formula node.
    It only works when I put a number as.
    float64 al[5];
    ,but I don't know beforehand how many elements I need, so I cannot use this.
    Please help! This is so stupid.
    Thanks

    Don't define your array in your formula node.
    Initialize the array as the size you want and pass it in as an input into the formula node.
    Are you sure you even need to use a formula node?  Can you implement your formula using all native LabVIEW functions?
    Message Edited by Ravens Fan on 10-07-2009 11:51 PM
    Attachments:
    Example_VI_BD.png ‏3 KB

  • Empty array of unknown size in formula node

    I have to declare an empty array say, P of unknown size in formula node. How to do that?

    Hi sukhiray,
    an empty array has a known size...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How can I increment the index of an array in a formula node?

    Hi,
    I need some help with the formula node. I need an array, that increment every iteration of the code in the formula node. I need it to save amplitudes.
    I thought i could do this with i++; i is the variable for my index.
    Martin
    Solved!
    Go to Solution.

    Hello,
    does it sound well to you ?
    @+
    Tinnitus
    ps: sorry posts mixed
    Message Edité par tinnitus le 12-15-2008 03:05 AM
    CLAD / Labview 2011, Win Xp
    Mission d'une semaine- à plusieurs mois laissez moi un MP...
    RP et Midi-pyrénées .Km+++ si possibilité de télétravail
    Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
    Don't forget to valid a good answer / pensez à valider une réponse correcte
    Attachments:
    inc_node.vi ‏6 KB

  • How can I specify simple math like in a Formula Node but on the front panel?

    If the Formula node had a "text" property, that would work for me, because I could limit my inputs and outputs to N floating-point numbers.
    LabVIEW once had such a thing but it was in an add-on math library, and I don't remember what it was called.
    Solved!
    Go to Solution.

    Thanks; that led me directly to what I was looking for. A combination of "Parse Formula String.vi" and "Eval Parsed Formula String.vi" works perfectly for me!

  • 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 for array

    hi
      i want to convert the values of an array using a different formula for each value in the array.     Can i use formula node for this?    if yes how
    if no then is there any other method except for extracting each one individually and converting?

    kunal227 wrote:
    there are 16 elements in the array and the number remains constant (actually they are temp values acquired by a fieldpoint hardware).
    the formula is a linear conversion (for example y = m*x + C) corresponding to the calibration curve of individual thermocouple connected to the fieldpoint hardware.   every thermocouple has a different calibration curve and hence every element in the array is converted using a different linear formula.
    All you need is an array of [m] and an array of [C], all the same size as your data arrray. No formula node needed.
    (I think that's what mikeporter had in mind above)
    Message Edited by altenbach on 07-24-2007 03:38 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    CorrectedArray.png ‏4 KB

  • How do I get an array output on a Formula Node?

    My problem is simply that I cannot figure out how to get an output on a Formula Node to be an array. Documentation states that "you must declare local arrays and output arrays in the Formula Node" but doesn't say anything more than than. Attempts to put something like "float32 out[100];" for an array output called "out" fail.
    If anybody knows how you can do this or even knows if it is possible I would appriciate your help.
    Thanks,
    Naveen

    I found a typo in the formula node I was doing that was making the output not be an array. I don't think I was getting the error before but I was going to put together an example VI to attach here and I found it. So, thanks for your help even tho it was a stupid little mistake on my part.

Maybe you are looking for