LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

specifying max limit range in array

Hi,

 

I am stuck up with a problem . Though its trivial, i couldnt solve it. 

 

Consider a 2d array which containts any random number say  0 to 1000000 written in a spreadsheet file. But i am required to extract only the values in the range 0 to 50000 , and rest of it should be replaced with zero. there can be million values in the spreadsheet file. 

 

I am using labview of version 9. Any help on this is highly appreciated. 

 

thanks,

sarath

0 Kudos
Message 1 of 13
(5,192 Views)

Feed your 2-D array through 2 nested For Loops with auto-indexing turned on.  Inside the inner most For loop do the comparison, either pass through the value untouched or pass out a 0.  The output tunnels should also have auto-indexing turned on.  In the end, you'll have a 2-D array that matches the conditions you specified.

Message 2 of 13
(5,183 Views)

In Range and Coerce will work directly on a 2D array.  Since you want the values changed to something other than the upper coercion limit, you still need to run the results through loops.  Note that my image below uses a multiplier of 1E5 not 1E6.

 

Lynn

 

22250i2C205EB9DCBADCEA

Message 3 of 13
(5,160 Views)

Hi Johnsold,

 

this is a part of my full scheme of code. I am attaching the VI for your reference. i have tried the solution you gave to the best of my knowledge to fit in my code but in vain. basically i am trying to read a certain section of spreadsheet file and add all those files(containing array elements) and subtracting that with another set of files. Now I need to display only a range of values from the resulting array in the intensity graph. I am also required to do certain other functions, which is irrelevant at present. 

 

Right now i have appended your code and edited little, which i have attached for your reference. I couldnt attach my spreadsheet files which i use since it is 11mb each. Can you used any text file which you have and execute it.  Pls tell me where i am going wrong. Thanks for your prompt reply,. 🙂

 

Labview version: 9.0

0 Kudos
Message 4 of 13
(5,140 Views)

No chance to look at the attached VI, but just an alternate method to the nested For Loops.

 

22288i010048E9F5234ADE

Message 5 of 13
(5,127 Views)

In the middle of your VI, you have a pair of nested For Loops.  There is no reason to break those two functions apart.  The should be inside a single set of next For Loops.

 

But the big problem is with those loops.  You have empty 2-D arrays being auto-indexed into them.  A For Loop with an empty array being indexed into it will run exactly zero times.  Thus you get no results out of that loop.

 

Even if you did not have the empty array, your other array is a 1 element 2-D array with the number 30,000.  Thus each For Loop would only run 1 time.

 

I'm not sure why you didn't use any of the examples given to you.  If you want to use In Range and Coerce on your entire array for the same Max and Min values, those Max and Min values should be scalar constants inside the For Loops and not 2-D arrays outside the For Loops.

Message 6 of 13
(5,114 Views)

The empty arrays shouldn't be a problem because there is another array (filenames) feeding into the for loops- The for loops will iterate according to the largest array being fed into them and so will itereate as many times as there are values in the filname array

0 Kudos
Message 7 of 13
(5,092 Views)

MscSarat,

 

Ravens Fan gave you the reasons your VI did not work.

 

Darin.K showed a more elegant way of doing What I proposed.  I had thought that a better way probably existed, but had not figured out how to do it.

 

Tom9390,

 

Put a probe on any of the wires inside the for loops and you will find that the loops do not execute.  The for loop executes the minimum number of times it takes to consume all the autoindexed inputs or N, so it executes zero times when an empty array is autoindexed.  The help does not document this and probably should be improved.

 

Lynn

0 Kudos
Message 8 of 13
(5,080 Views)

@Tom9390 wrote:

The empty arrays shouldn't be a problem because there is another array (filenames) feeding into the for loops- The for loops will iterate according to the largest array being fed into them and so will itereate as many times as there are values in the filname array


Completely Wrong.

 

The loop will iterate the number of times equivalent to the smallest array or the value wired into the N terminal.  See the attached test.  When the loop runs zero times, the default value for the datatype will be output at the tunnels.  (Unless you use a shift register, in which case the value from the left hand shift register will pass to the right hand shift register untouched.)

 

0 Kudos
Message 9 of 13
(5,066 Views)

I have got the desired result. I retained one for loop instead of two. I didnt go for nested loop. I used the boolean function , thought it is simpler. IT works perfectly fine now.

 I have attached my VI for your reference. 

 

Thanks for your help.

0 Kudos
Message 10 of 13
(5,033 Views)