Filtering numbers in an array

Hello,
I have data in an 1d array and I want to remove the points less than a set value.  The points could also be changed to 0.
Thanks in advance for any help.
Paul

professorburnout wrote:
Hello,
I have data in an 1d array and I want to remove the points less than a set value.  The points could also be changed to 0.
Thanks in advance for any help.
Paul
if you only want to set the values<threshold to zero, see the attached code snippet:
Attachments:
Unbenannt.PNG ‏3 KB

Similar Messages

  • Search numbers from an array

    Hai
         Pls help me how to do this,
    My read CAN data is like this
           First frame -10 11 58 05 52 35 F1 52
    Conse. frame 1 -21 04 E8 52 10 E8 56 11
    Conse. frame 2 -22 E4 56 12 E4 62 11 E4
     i want to extract the red coloured numbers from the array.
    Thanks
    sk
    I am using LabVIEW 7.1 & NI PCMCIA CAN card
    Attachments:
    tttttt.vi ‏82 KB

    If instead you want to extract certain data bytes from each message, you should use the 'Index Array' function from the Array palette.
    This will extract individual elements from the array as specified by the connected Index inputs. The image below shows the setup needed to get the elements for your First Frame.
    Ed
    Message Edited by Ed Dickens on 01-18-2007 07:57 AM
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    Index Array.gif ‏13 KB

  • Feeding numbers into an Array

    Hi, I want to feed numbers into an array but its only using the first element. In my vi users can enter a number and this number needs to be then stored in an array. Any help would be welcome. Thanks

    like this maybe?
    Of course you would replace the random number with a control and use an event structure to spin the loop only if the input is changed by the user, for example.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AddNumbers.png ‏2 KB

  • Converting a string of numbers into an array of booleans

    For a homework assignment, I need to convert a string of numbers into an array of booleans.  The string is a bunch of random numbers (0-9) in sequence, with no spaces.  It looks something like this: 0123452348949230740329817438120947392147809231419.  I need to make it so that each even number represents a "True" boolean and so that each odd number represents a "False" boolean.  I think that I first need to convert each element of the string into a number, and then use a case structure (or something) to say, for each element of the array, "If even, then true.  If odd, then false," but I could be wrong.  Any suggestions?

    billko wrote:
    Hooovahh wrote:
    billko wrote:
    Sounds reasonable.  Think about the definition of "odd" and "even" and it will make life a lot easier. 
    I know you are trying to be vague but I'd like to give a key hint.  Use the Quotient and Remainder function.
    LOL maybe that was one of the objectives of the homework. 
    To be fair it sounds like there is more work that is needed.  A new user of LabVIEW will have a hard time figuring out how to process each character one at a time when it isn't in an array.  
    It's just that most people (me at least) stopped thinking about division with quotient and remainder after basic algebra.  I then of course changed my way of thinking when I used LabVIEW.  Still most of the time when you use division you want to know the fractional part as a decimal.  Thinking this way makes the problem more difficult then it needs to be.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Find unique numbers in an array.

    How would I find unique numbers in an array by using only one array?

    At the above codes, I use the String representation of the number that I want to find. I know that it is an easy example but it can give you an idea that how Hash works in Java.
    Give symbols(aliases) to your numbers which helps you to remember the each specific number, so you can find specific number by only using its symbol(nickname) instead of using its location which is more difficult to remember.
    import java.util.*;
    * ...Hashdescription...
    * @author  ...yourname...
    * @version 1.00, 2006/05/19
    public class Hash
         // properties
         ArrayList keys;
         ArrayList values;
         // constructors
         public Hash(){
              keys = new ArrayList();
              values = new ArrayList();
         // methods
         public void add(int val){
              values.add(new Integer( val));
              keys.add("" + val);
         public int get(String key){
              int index = keys.indexOf(key);
              return ((Integer)(values.get(index )) ). intValue();
         public static void main( String[] args)
              Hash list = new Hash();
              list.add(1);
              list.add(2);
              list.add(3);
              list.add(4);     
              list.add(5);
              list.add(6);
              list.add(7);
              list.add(8);
              list.add(9);
              System.out.println(list.get("3"));
    } // end of class Hash

  • How can I rank a group of numbers in a array or list

    Now I have a group of numbers :13, 4, 5, 10.
    I need a java algorithm to rank those numbers, the result will be like 4,1,2,3 after ranking.
    suppose there are same numbers in the source, for example: 13, 4, 4, 5, 6
    the result will be like 4, 1, 1, 2, 3 after ranking.
    Thank you for any help!

    Another alternative is to make a class which has two attributes
    1. number value
    2. rank
    make this class implement comparable so you sort it anyway you like. Below is a very close example of what you are looking for, just need to replace frequency with rank
    class ComparbleExample{
        private final String[] possibleNumbers = {"one", "two", "three"};
        private String[] inputNumbers = {"one", "two", "three", "one", "one", "four", "three"};
        private Number[] numbers;
        public ComparbleExample(){
            numbers = new Number[possibleNumbers.length];
            populateNumberArrayList();
            System.out.println("\n\nPrinting Unsorted Array");
            print();
            ArrayList<Integer> d;
            Arrays.sort(numbers);
            System.out.println("\n\nPrinting Sorted Array");
            print();
        public void populateNumberArrayList(){
            int frequency;
            for(int i = 0;i<numbers.length;i++){
                frequency = getFrequency(possibleNumbers);
    numbers[i] = new Number(possibleNumbers[i],frequency);
    public int getFrequency(String number){
    int frequency = 0;
    for(int i=0;i<inputNumbers.length;i++){
    if(number.equals(inputNumbers[i])){
    frequency++;
    return frequency;
    public void print(){
    for(int i = 0;i<numbers.length;i++){
    System.out.println(numbers[i]);
    public static void main(String[] args){
    new ComparbleExample();
    class Number implements Comparable{
    private int frequency;
    private String number;
    public Number(String number){
    this(number, -1);
    public Number(String number, int frequency){
    this.number = number;
    this.frequency = frequency;
    public String getNumber() {
    return number;
    public int getFrequency() {
    return frequency;
    public void setFrequency(int frequency) {
    this.frequency = frequency;
    public void setNumber(String number) {
    this.number = number;
    public int compareTo(Object o) {
    Number n = (Number)o;
    if(frequency < n.getFrequency()){
    return 1;
    }else if(frequency > n.getFrequency()){
    return -1;
    }else{
    return 0;
    @Override
    public String toString() {
    return this.number +", "+ this.frequency;

  • Grabbing numbers from an array of type double and outputting them into a text file

    In a program im creating i need to save some coordinates of a micropositioner i have into a text file,
    I have the coordinates saved into an array that has 6 digits of precision (6 places after the decimal point).
    I use the number to string conversion and wire that into the write to text file function in labview.  When i open the file
    the numbers that are only displayed are the ones to the left of the decimal point.  I know the number to decimal string function
    rounds the values so if i were to input 3.111111 it would only output the string "3" instead of "3.111111" . 
    So to get all the digits onto the file without rounding i multiplied the number by 10^6 but the decimal point will be lost at that point.
    Is there anyway i can convert numbers into strings without labview rounding to the nearest whole number also without having to multiply by 10^6 and without having to expect the user to know that the coordinates saved in a file are multiplied by an order of magnitude of a million ? 

    ed oh i guess i just missed that function on the pallete after i saw that the function went from number to hex, octal, etc. i assumed that the rest on that row would be some sort of conversion to a different base number, haha thanks.

  • How do I get a sub-array of even numbers from an array?

    I have a simple VI..
    First generate a 2D random numbers array. From this 2D array I have to show only the even numbers in a 1D array.
    I will thank you a lot!
    Solved!
    Go to Solution.

    take a look to what I've done.. I got a conflict with the case structure I used, this is, when the remainder is 0 then, store in an array, but if it's false(by default because in tru case is just wired) then store a zero.. My conflict was that I finally got an array of even numbers and zeros as the quantity of odd numbers.
    What I've done is resize the 2D array into a 1D and then sort it, then reverse the order so that the zeros of the array are all after the even numbers, then I used 'delete from array' from the index that zeros start, finally I got an array with only the even numbers, I have no problem with the result because the excercise asks me a range of random numbers from 13 to 69... but if it was from 0 to x all what I've done is no more efficient because I'd need the possible zeros that would appear by random generating.. I don't dominate arrays in labview, surely you have a completely more efficient solution to what I want
    Attachments:
    practica before exam.vi ‏15 KB

  • Comparing numbers in two arrays

    OK I am making a lottery program in Java. The idea is a user enters 4 numbers, they are saved to disk. A user then starts the draw which creates 4 random numbers and compares them with the numbers a user has chosen and sees if there are any matches. Here's what I have in my Do_Draw method
    public static void Do_Draw() {
            String input;
            int Numbers[] = new int[5];
            int[] numbers = new int[4]; //array declared
            int numBalls = 4; //integer
            int[] balls = new int[numBalls];
            for (int i = 0; i < balls.length; i++) {
                balls[i] = i + 1;
            for (int i = 0; i < numbers.length; i++) {
                int drawnBall = (int)(Math.random() * numBalls);
                numbers[i] = balls[drawnBall];
                balls[drawnBall] = balls[numBalls - 1];
                numBalls--;
                System.out.print(numbers[i] + " "); //print out numbers for user to see
                try {
                    FileOutputStream assfile = new FileOutputStream("a:/draw.txt", true); //true allows the file to be appended
                    PrintStream myOutput = new PrintStream(assfile);
                    myOutput.println(numbers);
    } //end of try
    catch (IOException e) {
    System.out.println("error writing to file, please check your disk");
    System.exit(0);
    } //end of error message
    JOptionPane.showMessageDialog(null, "The draw has taken place, Thank You");
    int matches = 0;
    for (int i = 0; i < numbers.length; i++) {
    for (int j = 0; j < Numbers.length; j++) {
    if (numbers[i] == Numbers[j])
    matches++;
    System.out.print("You have matched" + matches);
    I get a repeated message at the end, I know this but it does tell me if I have any matches. It always tells me I have no matches though. It compiles fine and looks ok but I am not sure why it is not matches. Cheers for all your help

    Hmm...you are trying to match numbers in number[] to Number[], but you do not assign any numbers to Number. I ran your program an Numbers is just full of zeros, so all you need is to enter the numbers the user wants into Number array and you should be fine...if this doesnt work, feel free to write me again.

  • Random numbers from an array?

    Hello everyone!
    I have this array: private int[] possibilities = {4151, 6570}; And I want the Random class to take one of these numbers, and store it in an int called 'requirement'.
    Like this: int requirement = random.nextInt(...); I know that this is possible because I did it before. I just can't remember what I used to put inside: random.nextInt(...); - As it's around a year ago I did it.
    So can someone PLEASE help me? :)

    int index = random.nextInt(posibilities.length);
    int requirement = posibilities[index];(Edit: Made more general).

  • Random Numbers in an Array - Please Help!!

    I just can't get it right. I have tried everything and it just won't work could you help me. I need to have an 8 element array and assign values excluding values in the range between 20 to 40 and excluding values in the range from 50 to 80. And I need to use the random method. Below is the code that I have created so far. Any suggestion?
    import javax.swing.*;
    public class MyArray
         public static void main (String [ ] args)
         JTextArea outputArea = new JTextArea ( );
         int myArray [ ]; //array declaration
         myArray = new int [ 8 ]; //allocating memory
         String output = "Array values at initializatioon ";
         output += "\nIndex\tValues";
         for ( int i = 0; i < myArray.length; i ++)
              output += "\n" + i + "\t" + myArray [ i ];
         output += "\n\nArray values after assigning values within the range of 15 and 25";
         for ( int i = 0; i <myArray.length; i++)
              myArray [ i ] = 1 + (int) (Math.random() * 19) ? (10*Math.random() + 39) : (1*Math.random() + 81);
              output += "\n" + i + "\t" + myArray [ i ];
         outputArea.setText (output);
         JOptionPane.showMessageDialog (null, outputArea,
              "Array Value before and after",
              JOptionPane.INFORMATION_MESSAGE);
         System.exit ( 0 );

    How about:
            Random rnd = new Random();
            int[] numbers = new int[8];
            for (int index=0; index<numbers.length; index++) {
                int rNum;
                while(((rNum = rnd.nextInt(Integer.MAX_VALUE))>=20 && rNum<=40) || (rNum>=50 && rNum<=80));
                numbers[index] = rNum;
                System.out.println(rNum);
            }

  • Adding numbers in an array

    i have an integer array called nums and i want to add all the 15 numbers in it. Instead of doing nums[0] + nums[1] + nums[2] + nums[3] etc. is there a better way to do it?
    maybe something in a while or for loop like nums[0] + nums[1++].
    anyone know what i can do?

    a loop would be a good idea now, wouldn't it ?
    // declare and fill your array here
    int[] numbers = new int[15] ;
    java.util.Random rnd = new java.util.Random() ;
    for (int i = 0 ; i < numbers.length;i++) {
        numbers[i] = rnd.nextInt() ;
        System.out.println ("numbers["+i+"]\t" + numbers) ;
    // array is filled....
    long sum = 0 ;
    for (int i = 0 ; i< numbers.length;i++) {
    sum += numbers[i] ;
    System.out.println("numbers["+i+"] : " + numbers[i] +", total so far : "+ sum) ;
    System.out.println("total : " + sum) ;
    The problem you might encounter is that if you add integers up, you might someone get a result that is larger than maxint. So I declared the sum as a long (which of course can end up with the same problem with a large number of large integers...)
    Is that, what you had in mind ?

  • [Question]how to count the occurance of numbers inside the array

    im just practicing my java skill but i cant get my program work can you give me guys some idea on how to determine a number that occured more than 1 inside the array e.g i have 10 elements and inside of my offset i have
    1,2,5,4,5,6,5,8,9,5
    and what im planning to do is count the occurances of the number who occures more than 1 and for that 5 occur 3 times how my program can know that i use for loop but cant figure out how to filter the occurances of numbers inside
    my offset
    thank's

    Encephalopathic you said put - 1 instead i did - 2
    public class sample
       public static void main(String args[])
          int num[] = {2,2,2};
          int index1, count = 0, find = 0;
          for(index1 = 0; index1 < num.length - 2; index1++)
             for(int index2 = 0; index2 < num.length; index2++)
                if(num[index2]==num[index1])
                  find = num[index2];
                  count++;
             System.out.println("i found " + find + " " + count + " same number inside your offset");
    }output is:
    i found 2 3 same number inside your offset
    but another question is what if i want my program to tell the other number that occur 1 time
    like this:
    i found 1 2 same number inside your offset
    i found 2 0 same number inside your offset
    i found 1 2 same number inside your offset

  • Store generating numbers as 2D arrays

    Hi,
    I am getting voltage and position of a PZT as numbers which are changing continuously. Now my question is that how can I store these numbers (marked in the image by red circle) as 2D arrays?
    thank you in advance.
    Solved!
    Go to Solution.
    Attachments:
    position-voltage.png ‏20 KB

    Hello again Optic,
    Now at this point I have to admit that I don't know exactly what you are aiming for in your final array layout, but I do notice a couple of things in your diagram that are interesting.
    One is you are building a 3-dimensional array in the outer loop, inserting each consecutive 2D array into the master array along one dimension.  Also, you seem to be doing this upside down from what I'm used to seeing; usually the parent array is the first parameter of the build array VI, and the insertion is below it.
    I would think you would want the new data to be appended onto the existing data, not inserted along a new dimension?  There is a on option on the build array VI called "concatenate inputs" that you can find by right-clicking on it.  I have this option set true on the build array VI in the top-right of this new VI picture.
    I cleverly made my test VI in a released version of LabVIEW so code is attached as well as the image.
    Edwin!
    Attachments:
    arrays2.jpg ‏26 KB
    array2.vi ‏12 KB

  • How to Add Numbers in an Array

    I understand that you would use a for loop, but I don't know what would come after:
    for(int b=0; b<array.length; b++){ Please help!!!
    I have tried this on my own, but nothing is working!!!
    Thanks in advance
    Edited by: Sevan on Oct 12, 2008 2:12 PM

    I finally figured it out!!!
    Here is what I did:
    import java.util.*;
    public class Grades
        public static final void main(String[] args)
            Scanner scanner = new Scanner(System.in);
            System.out.println("Insert Number of Grades to Average");
            int x = scanner.nextInt();
            int[ ] array = new int[x];
            System.out.println("Insert Grades Below");
            for(int i=0; i<x; i++){
            int r = i+1;
            System.out.println("Grade Number " + r);
            array=scanner.nextInt();
    if(array[i]<=100 && array[i]>=0){
    continue;
    else{
    System.out.println("Error: Only Enter Grades Between 0 and 100");
    return;
    int h=0;
    for(int b = 0; b < x; b++){
    h = h+array;
    double y = h/x;
    System.out.println("The Student's Average is " + y);
    The solution starts 5 lines from the bottom.
    However,
    I feel like there is an easier solution to this problem
    If there is, please let me know!!!
    Thank you

Maybe you are looking for

  • Error while installing htmldb from the companion cd (10R1)

    Hello team, i needed to install apex on an existing 10gR1 database running on Windows Server 2003 SR2, so i started off by installing the companion cd stuff coming with that release. Oddly enough, i successfully installed the http server but the html

  • How to install apex 4 with Oracle Fusion Middleware Web Tier Utilities

    Hi all, Does any one know how to install apex 4 with Oracle Fusion Middleware Web Tier Utilities ? I follow the instructions http://download.oracle.com/docs/cd/E17556_01/doc/install.40/e15513/toc.htm but there's no directory called ORACLE_HTTPSERVER_

  • Default customer order block

    Hi experts, When creating customer master, how to default order block to customers? For e.g., when saving a new customer, order block is set in customer master automatcally. Pls help. Thx.

  • Identify this technique or effect please i need help.

    i recently started using adobe after effects and premiere and i wanted to know if this video is an effect or technique. i desperately want to know how to do this video effect from this wiz khalifa video from atlantic records. here is the link Wiz Kha

  • Can't download elements on 2nd computer

    I got a new MacBook Pro laptop and am tring to download Elements 11, which I purchased and downloaded about year back on my old IMac.  Since dont have actual disc, how do I do this?  When I open adobe downloader assisstant it says "This application c