In range and coerce with complex numbers?

I have an array of complex numbers with these numbers I need to set to 0 all numbers whose real parts are negative. With "in range and coerce" I can split the array into real and imaginary then set all negative numbers to 0 then recombine the complex part but that still leaves me with 0+ai numbers that should be 0. How can I also set the complex part to zero for the negative numbers?

Hello,
You can use the following fonction in a for loop with your array.
Michel

Similar Messages

  • I have an array in which I want to check and see if it falls within a certain range with about 7 different ranges. I have tried the range and coerce function but something is going wrong.

    Also, I have a timer that lets me know how long the trigger has been active. I want to know if it is possible if that time would be reset everytime the trigger goes off.
    Attachments:
    Code.vi ‏113 KB

    1. Do not run using the Continuous Run button! This is intended only for certain types of trouble shooting and not for normal operation.
    2. Put a while loop around your entire program.  Add a stop button wired to the stop terminal of the loop.
    3. Then you can replace all the feedback nodes with one shift register with the input expanded to five elements. Sum the three bottom ones for your averaging.
    4. Nothing is wrong with the In Range and Coerce.  You should only check it when you have data.  That is what the Data Available output from Trigger and Gate is for.
    5. I am not sure what you want to reset for your timer or exactly when, but it should be possible.
    6. I did not try to figure it all out but you may not need the timer while loop once you wrap the loop suggested in 2 around the rest of the code.  You may be able to move the shift registers to the outer loop. 
    Lynn

  • Having trouble converting array to spreadsheet string, storing the file and coverting back to array with complex numbers

    I am working with a network analyzer. I have arrays made of 5 columns the first consisting of an integer and the next four consisting of complex numbers. I am converting the array into a spreadsheet string and then saving the file using the write characters to a file VI. That seems to work well as when I open the file in Excel all the data is there. However when I try to reverse the process, open file and convert back to array, I loose some of the data. Specifically the imaginary parts of my complex numbers are all going to zero. I have narrowed down the problem to be in the conversion from spreadsheet string to array and vice versa. I
    think the problem may be with the 'format' input to the VI. I do not have an adequate resource for this so I am not sure what to put in to accomplish my task. Any takers?

    Hi Biz
    I don't think there is a direct way of converting a complex number to a
    string, so when you convert the array to a spreadsheet string, the
    numbers would be converted to real data.
    However, you could try separating the real and imaginary parts using the
    "Numeric: Complex to Re/Im" function, and then store these - either in
    separate files or in adjacent columns/rows in the same file. Then, when
    you read in the data again, use the "Numeric: Re/Im to Complex" function
    to put the two "halves" together.
    If you actually want Excel to interpret the numbers as imaginary, then
    you'll probably want to create a string for each complex number of the
    form "Re + Im*i" (after separating the Re and Im parts), by using
    "String:Format into String" with 2 numeric inputs and the format string
    "%f+%fi".
    Reading the data back into Labview then would require splitting the
    string into the 2 pieces by using "Stringcan from String" with 2
    numeric outputs (smae precision as original numbers specified by the 2
    Default Value inputs) and the same format string "%f+%fi", and then using
    the above-mentioned "Numeric: Re/Im to Complex" function. It worked for
    me, so if you can't follow what I am describing, send me an email and I
    can email you what I did (LV 5.1.1).
    Paul
    Biz wrote:
    > Having trouble converting array to spreadsheet string, storing the
    > file and coverting back to array with complex numbers
    >
    > I am working with a network analyzer. I have arrays made of 5 columns
    > the first consisting of an integer and the next four consisting of
    > complex numbers. I am converting the array into a spreadsheet string
    > and then saving the file using the write characters to a file VI. That
    > seems to work well as when I open the file in Excel all the data is
    > there. However when I try to reverse the process, open file and
    > convert back to array, I loose some of the data. Specifically the
    > imaginary parts of my complex numbers are all going to zero. I have
    > narrowed down the problem to be in the conversion from spreadsheet
    > string to array and vice versa. I think the problem may be with the
    > 'format' input to the VI. I do not have an adequate resource for this
    > so I am not sure what to put in to accomplish my task. Any takers?
    Research Assistant
    School of Physiotherapy, Curtin University of Technology
    Selby Street, Shenton Park, Western Australia, Australia. 6008
    email: [email protected]
    Tel. +61 8 9266 4657 Fax. +61 8 9266 3699
    "Everyone who calls on the name of the Lord will be saved." Romans 10:12
    "For all have sinned and fall short of the glory of God, and are
    justified freely by his grace through the redemption that came by Christ
    Jesus." Romans 3:23-4

  • In range and coerced problem

    Good day,
    I'm using labview 2009 and I have a problem using in range and coerced VI. The problem is that I want to map one analog value that goes from 0 to 12 to a scale of 0 to 20 and the VI in range and coerced but this VI is ignoring the numbers after the point. I already set the diferent values for the lower and higher limits but it keeps happening.
    I posted my VI so you can see the trouble I'm having.
    Best regards.
    Esteban Gonzalez
    P.D. The error is easy to see when the numeric indicator with the label "Current" have a value of 9.
    Solved!
    Go to Solution.
    Attachments:
    VI - Comparacion Corriente.vi ‏33 KB

    First of all, you probably would need much less code, maybe the size of a postage stamp. (hint: threshold array)
    You have overlapping conditions, for example between 11 and 11.1, two LED will be lit.
    You have gaps where it fails right between two LEDs.
    LabVIEW Champion . Do more with less code and in less time .

  • In range and coerce function does not always return a correct result

    I passed 20E6 as DBL to "upper limit" input of "in-range and coerce" built-in VI, and also passed 20E6 as DBL to the X input of the VI, yet it says that it is not in range.  (Note: lower limit was hardwired to 0.)
    Apparently, there is some kind of roundoff error going on with LabVIEW.
    I've seen this before when just wiring 2 doubles of the same value to an "=?" built-in VI.
    When I display 30 digits or so, the values then display slightly differently.
    How do 2 numbers which were entered by ME (not anything else) precisely as 20E6 manage, over time or by passing thru VIs, or by being copied & pasted -- or whatever -- to become "different"?

    This simpliest 'In Range and coerce' does not work on my setup (8.0 and XP). The result should be 0 but it returns -5.
    Attachments:
    Coerce Not Working.vi ‏8 KB

  • [Bug?] In Range and Coerce Comparison Mode

    It seems that changing the Comparison Mode of the IR&C function with Arrays or Clusters attached does not trigger Type Propagation, or whatever is responsible for selecting the proper instance.  For example, if I wire up three arrays to the inputs of IR&C, change comparison mode to Compare Aggregates, then create an Indicator from the In Range? output, the result is the wrong indicator and a broken wire.  Likewise, I can change the mode on an IR&C function with a wired In Range? output and it will not break the wire until a later change triggers a recompile or type propagation.
    LV10 (not SP1) and Win7.
    Solved!
    Go to Solution.

    Hi Darin,
    As mentioned, that CAR refers specifically to clusters and the 'In Range?' boolean output of the In Range and Coerce function. The specific VI that showed the issue always had an In Range output of true for all elements of the cluster except the first. However, it is worth note that the Coerced results showed correct behavior, unbundling showed correct behavior, changing the numeric representation of the compared elements (even changing back to the original representation of U32) corrected the behavior, this error is fixed in LabVIEW 2011, and when I recreated the VI from scratchn in LabVIEW 2010 it behaved as expected.
    So, it is very unlikely that the error fixed in this CAR will impact your use of the In Range and Coerce function.
    Matt
    Product Owner - NI Community
    National Instruments

  • In range and coerce

    I want to make a VI that will show me how many random numbers from 0-100 range should be generated. After that VI should draw a histogram, showing how many percent of numbers were from 0-49 range and how many from 50-99. There should also be two numeric indicators showing how many numbers were from both of those ranges.
    I use "In range and coerce", but for example if I generate numbers: 78, 97,74;
    First "In range and coerce" (50-99)" will show output: 78, 97,74, which is correct.
    But second "In range and coerce" (0-49)" will show output 49,49,49 which I dont want; I just want to show in this example one zero.
    After that I will connect both input to histogram, will be OK ?
    See picture, thanks
    Rookie; LV 2011 on WIN 7
    Solved!
    Go to Solution.
    Attachments:
    project 3.vi Front Panel _2.jpg ‏68 KB

    Yes I know that but I have probelms, that from 3 input numbers,"in range and coerce" function make:
    78, 97,74  and  49,49,49;
    From 3 input numbers I need 3 output not 6 :/. If it's not in range, why than show 49,49,49 ?
    After that I will make front side as this on picture
    Rookie; LV 2011 on WIN 7
    Attachments:
    project 3.vi Front Panel _2.jpg ‏68 KB

  • In range and coerce oddity

    From the v. 8.6.1f1 help file
    To change whether the function includes the value wired to upper limit or lower limit, right-click the function and select Include upper limit or Include lower limit from the shortcut menu to include or remove the value in the range. These options only affect the result of In Range?. The function always coerces x to the exact values of upper limit or lower limit, regardless of whether you select Include upper limit or Include lower limit from the shortcut menu.
    Is there a reason for this?  I was trying to coerce something and it took me a fair amount of time to realize what was happening and to look into the help file.  Frankly, I'm kind of surprised I haven't run into this yet.
    Tim Elsey
    LabVIEW 2010, 2012
    Certified LabVIEW Architect

    If your array size is 10, you're telling the function to coerce between 0 and 10 which are actually 11 elements.
    That's wrong.  I understand what you're trying to do with the "do not include upper limit" but that's not what it is there for.  It's there for only the "In range" portion of the "In range and coerce".
    Just input a -1 before the in range and coerce function and you're all set.
    The function works exactly as it says on the box.  Adapt and survive.
    Plus, you openly admit that your "solution" creates additional problems.  This is far too small an issue to warrant revising how a quite frequently-used primitive should behave.  If you want you can create your own sub-VI (inline it if you want) to do exactly what you're looking for.  This, at least, won't break everyone else's software who uses this function properly.
    Shane.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • In range and coerce on time stamps

    Is there any reason why I shouldn't be able to use in range and coerce on time stamps?  In this VI the value is not being coerced, but the output for in-range is false.  With values out of range, it DOES coerce the output. 
    Jim
    LV 2013
    Solved!
    Go to Solution.

    lmtis wrote:
    What a NOOB mistake!
    Thank you nathand
    LOL The next noob minstake is forgetting to mark the person's post that solved the issue for you as the solution. 
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • In range and coerce binary operation

    How do I implment the "in range and coerce" function with binary operation?  I want to do that to make my fpga code more efficient.
    Kudos and Accepted as Solution are welcome!

    What exactly do you mean by "binary operation"?  I am assuming you are dealing with integers here to make life simple.
    The In Range portion is just a simple Less Than and a More Than with an AND ( x < UL && x > LL).  The Coerce portion would likely be best done with Select nodes based on the Less Than and the More Than comparisons.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • SVD with complex numbers

    I'm working on creating a SVD class using complex numbers. I have an adaptation of the Jama ( http://math.nist.gov/javanumerics/jama/ ) implementation coded which works great with complex numbers with only a real part, but fails when the imaginary is present. I also coded up a port of numerical recipes' ( http://www.nr.com ) implementation, but am unable to get it to converge. I'm 99.9% sure that the problem does not exist in my complex number class as it has worked fine up until now.
    Anyhow, what I'm wondering is if anyone has a Java SVD for complex matrices that I could look at and/or use?
    Thanks in advance,
    m

    It wasn't working when I tried it a few months ago. I found the bug in the database - it's been long-standing. Given that Sun doesn't appear to be supporting Java3D very well, I doubt it'll ever be fixed.
    Besides, that SVD algorithm is only for real matricies, I believe. - MOD

  • Latch an "In Range and Coerce" Output until Reset

    I have numerous voltages and signals that I am reading from an PXI system.  Each of these signals needs to fall between a minimum and maximum.
    Right now, the entire "program" is running inside of a While Loop.  Each signal is being read and then passed to an "In Range and Coerce".  This function is working well, in that it notifies me when the value falls outside of the maximum and minimum.  But what I need to do is to "latch" the output from the "In Range and Coerce" until I have completed other functions also running in this While Loop.
    I'm very new to LabView and a hardware engineer on top of that.  I know that the way I'm doing this is probably not the best way.  I am open to any suggestions.
    Thanks,
    -Steve

    It sounds to me like the kind of "latching" you're looking for is automatically available to you as a side-effect of LabVIEW's "dataflow" nature.
    Once a value exits an output terminal of the "In Range and Coerce" function, all wire paths connected to that output will receive the exact same value. I.e., once a value gets on a wire, it remains constant through all branchings connected to that wire.  If you turn on debug highlighting mode, you'll see what this means more visually.
    A common source of LabVIEW problems for people experienced in text languages is overuse of local and/or global variables.  Perhaps this is the root of your issues with "latching?"
    In text languages, data is contained within and "transported" by variables.  In LabVIEW, data is contained within and transported by wires.  In LabVIEW, variables and controls/indicators are just termination points to allow the data to be displayed or passed to/from calling functions.  They aren't really important in and of themselves.
    -Kevin P.

  • Upper Limit In Range and Coerce

    I found a bug with the In Range and Coerce function, and I tried searching but I didn't see if anyone posted the issue before. Anyways, the Lower Limit is inclusive for the In Range indicator and the Upper Limit is not:
    Using U32, set the Upper limit to 5 and lower limit to 1. When x = 1, In Range is True, and when x = 5 In Range is False.
    Took a little bit of time to figure out why my code wasn't working... but just fyi if no one is aware.

    That's kind of a unique situation... I was thinking more likely to see if an array index is valid. In my mind inclusive is intuitive, but I guess I wouldn't have found out about the setting if it was intuitive.

  • In Range and Coerce, STRING

    Hola a todo el mundo,
    La funcion "In Range and Coerce" para cadenas de caracteres, tiene un comportamiento que no acabo de entender.
    Si mi limite superior es z y mi limite inferior es a, si pongo d obtengo un PASS. Hasta aquí todo correcto.
    ¿Por qué obtengo también un PASS si pongo d seguido de cualquier texto? ¿Como es posible que solo evalue el primer digito?
    Es decir: "alaglhzafgkhjzs" esta dentro de "a" y "z"??         ......      al parecer la respuesta es sí.
    Con imagenes:
    Muchas gracias por todo

    Hola de nuevo,
    He hecho un vi que realiza lo que esperaba encontrarme. Lo dejo en Labview 8.5 por si a alguien le ha sucedido lo mismo.
    Gracias
    Adjuntos:
    In Range String.vi ‏14 KB

  • Hp 35s integrating with complex numbers/functions

    Are there any examples of how to integrate a complex function for
    the HP 35s..the manual suggests its possible..but, I can not find one
    example...anywhere... I am just interested in testing.....I do
    not want to break things into parts etc...I just want to try
    e^z for example, where z is complex..any help?
    I have tried xiy, rTheta, x+iy...syntax errors or non existent..funny

    Hi,
    The manual states that complex numbers can be used with EXP(x), but it does not mention anything about using complex numbers for integration. Edit: I missed some text in the manual, see below.
    As far as I can tell it cannot do integration with complex numbers. (The 50g can do this.)
    However, you may get a more definitive answer if you ask your question here:
    http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/forum.cgi
    EDIT: that forum has moved to a new version:
    http://www.hpmuseum.org/forum/forum-4.html
    Note: I do not work for HP, I just like playing with calculators :-)

Maybe you are looking for