LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

comparing elements in 2d array

Hi all

 

I need a solution. The problem is I have a 2-d array of numbers. I have to display a array subset such that the elements in the first row fall in the ranges provided by me through user prompt.  

0 Kudos
Message 1 of 11
(7,343 Views)

Hi 049982856...,

use the index array function to get an sub array of the first row. You can connect this array (if this are numbers) directly to the in range function. You can then check with an "AND Array elements" function if all values are in range or you use a for loop to sort them out.

 

Hope it helps.

Mike

0 Kudos
Message 2 of 11
(7,341 Views)

You should provide a bit more detail. Are you trying to coerce the first row and display the coerced row as an indicator? Or, are you trying to replace the row with the coerced values? Or...

 

If you just want to display the first row coerced, then you just need to use the "coerced" output of the In Range and Coerce function. That will return the values coerced to the range you specified. 

0 Kudos
Message 3 of 11
(7,299 Views)

 


I need a solution. The problem is I have a 2-d array of numbers. I have to display a array subset such that the elements in the first row fall in the ranges provided by me through user prompt.

 

 

What do you mean by user prompt.Thought i will confirm before trying it

Do you mean from an input array there should be a prompt and user will input new values and if the new values are between certain range then the element will get updated else it will be ignored.Is my understanding right? 

0 Kudos
Message 4 of 11
(7,292 Views)
its like i have a 2d array of numbers in increasing order. i input a number and i have to get the output array as all the elements that are less than it in the same order.( or rather get a subarray upon comparing the elements )
0 Kudos
Message 5 of 11
(7,275 Views)

04998285626 wrote:
its like i have a 2d array of numbers in increasing order. i input a number and i have to get the output array as all the elements that are less than it in the same order.( or rather get a subarray upon comparing the elements )

 

Sorry, it still makes no sense.

 

  • A 2D array has two dimensions, so the word "increasing" is not cleary defined. Increasing with the row index? column index? both?
  • You cannot remove single elements from a 2D array. You can only remove entire rows or columns.
  • The term "same order" makes little sense for a 2D array

 

Please show un an example array of numbers and indicate what the solution should be.

0 Kudos
Message 6 of 11
(7,272 Views)
Message Edited by muks on 08-23-2008 03:31 AM
0 Kudos
Message 7 of 11
(7,248 Views)

Sorry u meantioned 2d array so is this what u want?

 

 

Message Edited by muks on 08-23-2008 03:35 AM
Message 8 of 11
(7,245 Views)
If my understanding is wrong then as altenbach suggested can u diagramatically describe what ur input and ur expected output should be?
Message 9 of 11
(7,242 Views)

04998285626 wrote: 
...The problem is I have a 2-d array of numbers. I have to display a array subset such that the elements in the first row fall in the ranges provided by me through user prompt.  

And...


04998285626 wrote:
its like i have a 2d array of numbers in increasing order. i input a number and i have to get the output array as all the elements that are less than it in the same order.( or rather get a subarray upon comparing the elements )

OK, let's try to interpret this once more in clearer language. Apparently, the first row has some significance.

 

Maybe only the first row is increasing in value and we want to keep the subset of the 2D containing all columns that are below a threshold in the first element. Since the values in the first row are increasing, all we need to do is find the column index where the first element is too big, and then take the subset of the 2D array up to this point. Here is a solution for this interpretation of the task.

 

You still might need to adjust for detail, e.g. use "greater or equal?" instead of "greater?" depending on your exact needs.

 

 

 

Message Edited by altenbach on 08-23-2008 11:19 AM
Message 10 of 11
(7,225 Views)