From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Discussions au sujet de NI LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Condition avec tableau 2D

Solved!
Go to solution

Bonjour, j'aurais besoin d'aide sur un projet sur lequel je commence à bloquer un peu.

 

J'effectue l'acquisition de trames que je reçois sous forme de tableau 2D d'une taille (10.000 lignes,12 colonnes) quelque soit le nombre d'acquisition (le tableau se remplira de 0 à la fin si le nombre d'acquisition est inférieur à 10.000). Je vous joints au post un exemple d'extraction. La dernière valeur reçue s'ajoute en début de tableau.

 

- J'aimerais pouvoir arrêter ma boucle While lorsque la dernière ligne est différente de [0 0 0 0 0 0 0 0 0 0 0 0]; je n'arrive pas à manipuler les comparateur avec des tableau de booléen, je ne sais pas si c'est possible ou non de cette manière.

 

- J'aimerais aussi pouvoir trouver l'indice d'une ligne sur laquelle se trouve en colonne 4, 5, 6 et 7 deux valeurs particulière, exemple 0 6 0 128:

 

Tableau.jpg

Merci par avance pour le temps passé sur ce sujet  😀

 

0 Kudos
Message 1 of 13
(1,952 Views)

Not sure how well google translate worked on your post.

 

-it is not clear how many elements are replaced with each iteration (one column? A 2D array with a fixed number of rows? A 2D array of variable row length?)

-you can keep count (simple integer in a shift regsiter) how many values are added and compare with the final size.

 

To find the existence and position(s) of a given subset of elements, you need to iterate over all possible subsets. Are these integers?

 

Please attach a simplified version of your VI.

0 Kudos
Message 2 of 13
(1,926 Views)

On ne sait pas comment est implémentée ta boucle while alors difficile de t'aider. Poste ton code.

 

note: comme tu connais la taille de ton tableau 2d pourquoi n'utilises-tu pas une boucle FOR?

 

Ben64

0 Kudos
Message 3 of 13
(1,911 Views)

@ben64 wrote:

note: comme tu connais la taille de ton tableau 2d pourquoi n'utilises-tu pas une boucle FOR?

 


The number of iterations is only known if a fixed number of elements is added with each iteration. Thus my question above. We clearly need more info.

0 Kudos
Message 4 of 13
(1,904 Views)

It says that he always receive a 10 000 X 12 array whatever the number of acquisition, if the acquisition is less than 10 000 lines it is filled by zeros. But clearly there's a lot of missing info.

 

Ben64

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

It wasn't entirely clear. My understanding was that the final size is 10k rows, and the array is initialized with zero, then filled with real data as it arrives. The problem was to determine once all rows have been filled, i.e. when the last row is no longer all zeroes. Hard to tell without seeing code....

0 Kudos
Message 6 of 13
(1,882 Views)

quelque chose comme cela ?

test.png

0 Kudos
Message 7 of 13
(1,876 Views)
Solution
Accepted by topic author Michel_Dupuy

@thib_fr wrote:

quelque chose comme cela ?

test.png


This is incorrect for the general case because DBL numbers can be negative and your loop would stop of a row is [-1, 1, 0, 0...] for example. Are all values guaranteed to be positive integers? Values seem to be U8 range, so it is not clear why the file wastes all these bits for decimal points and triple decimal zeroes. We all know that equal comparisons should never be done with floating point numbers (e.g. DBL), so I recommend using an integer datatype.

 

There is also actually more than one row (eight!) that matches the pattern, so we need to keep the entire array of solutions.

 

Here's a slight modification that is probably safer (of course it is not clear if this is the solution).

(The ""last index" is the index of the row with all zeroes)

 

altenbach_1-1599898881772.png

 

 

 

Message 8 of 13
(1,869 Views)

Sorry for the language concern. My first message was:

 

Hello everyone, please I need your help on a project on which I can no longer move forward.

 

I am acquiring frames which are stored in a 2D array with a fixed size of (10.000 rows, 12 columns), whatever the number of acquisitions (the array will be filled with rows of 0 at the end if the number of acquisitions is less than 10.000). I attached to this post an extraction example. The first value is stored at the end of the array and the last one at the beginning.

  • I would like to stop the While loop when the last row (the 9999th) is different than [0 0 0 0 0 0 0 0 0 0 0 0]; I don’t really know how to manipulate comparison operators whith boolean arrays.
  • I would also like to find the index(es) of the row(s) on which are present specific values on column 4 / 5 / 6 and 7 ; for example 0 6 0 128 on the picture below :

Michel_Dupuy_0-1599905456772.jpeg

 

Reply to Altenbach first reply:

Thanks for replying to the post, and sorry for the language concern I should have written it in English.

 

  • Each frame corresponds to a row; so, 1 row is replaced on each iteration. The 2D array is fixed in a subVI corresponding to a device library that I cannot modify. Each value represents an 8 bits unsigned integer from 0 to 255.

I'll will probably devide the two tasks on two subVIs. Here are the extracts of how I am trying to implement the codse (not comfortable with array handling), there are probably more than one correction on those extracts:

 

1/ Stopping the while loop:

image.png

2/ Finding the indexes:

 

image.png

 

Thanks again everyone for your solutions and for the time spent on this post.

0 Kudos
Message 9 of 13
(1,861 Views)

Thanks for this solution @ , so the  "logical AND for array" is required to handle boolean array.

 

Am I right if I compare only the last row by this way to stop the while loop:

image.png

 

And for the matching rows:

 

image.png

 

Thanks again

 

 

0 Kudos
Message 10 of 13
(1,852 Views)