Discussions au sujet de NI LabVIEW

annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 

Calcul de moyenne pour un tableau 2 d

Résolu !
Accéder à la solution

Bonjour, je voudrais calculer la moyenne de chaque ligne en utilisant le registre à décalage mais je ne vois absolument pas comment faire. Je vous joint une photo.
Merci d'avance pour votre aide.


Capture d'écran 2024-03-03 141545.png

0 Compliments
Message 1 sur 11
863 Visites
Solution
Accepté par Auree

Try maybe something like this?

 

altenbach_0-1709483942918.png

 

altenbach_1-1709484042433.png

 

 

Your code makes absolutely no sense. Adding a scalar value to an empty array in a shift register will return an empty array, no matter how often you do it. Your division should probably swap the inputs. You only need exactly one "5" diagram constant because they need to be identical for your code would work correctly. If you want rows of 7 elements in the future, you currently would need to make identical changes in several places, potentially leading to mistakes. If you don't want to use the mean primitive, you can do the average explicitly, e.g. as follows:

 

altenbach_0-1709484506842.png

 

And if you want to do the sum in a shift register, here's how that would look like:

 

altenbach_1-1709484651411.png

 

 

Also be aware that your numbers are currently not "fair" because the highest and lowest possible random value will only occur with half the probability of all the others. You should round up or down instead of "nearest" if this is a concern.

Message 2 sur 11
842 Visites

Subject: LabVIEW Grade Calculation System

 

Hello, thanks you for your reponse


I am a bit lost and seeking guidance on a LabVIEW project I am working on.

I am trying to create a system where users can input their grades (for example, in mathematics, sports, etc.), and the system calculates their overall average. If the overall average is greater than 10, I want the system to display "PASSED."

 

Could someone please guide me on how to approach this task in LabVIEW?

 

Thank you in advance for your assistance!

0 Compliments
Message 3 sur 11
785 Visites

What have you tried and where did you get stuck? Be specific!

0 Compliments
Message 4 sur 11
778 Visites

I try to calculate the average of each row of the table to then display "allowed" when the average is greater than 10 otherwise "not allowed" but I block for the calculation of the averages


Capture d'écran 2024-03-04 164540.png

0 Compliments
Message 5 sur 11
773 Visites
 

@Auree wrote:

I try to calculate the average of each row of the table to then display "allowed" when the average is greater than 10 otherwise "not allowed" but I block for the calculation of the averages

altenbach_1-1709567715608.png

 

You simply need to start with the basic tutorials! You cannot program in LabVIEW without knowing the basics. Even learning debugging tools such as execution highlighting and probes will tell you want's happening (or not).

 

  • Adding an empty array to any array will result in an empty array forever.
  • You want the average of each row (I guess) but your code seems to be a broken attempt to average all elements of the 2D array (which would not even need a loop!). We already showed you to create an average of each row. You can then compare the average to your key value and output a relevant element of a string array.
  • Wiring N is typically incorrect when autoindeixng. If the input array only has one row, it will iterate once, not five times. The smaller always wins!
  • Posting very ugly code pictures is pointless. (wires flowing in all directions, way too many wire bends, wires hidden behind structures, useless terminal labels ("Array 2", "error 2"), etc.).
  • Once you write clean code with useful labels, the probability of making mistakes is 10x less!

LabVIEW even has a tool where you can lookup what your error means. Did you do that? Obviously, you cannot take an average of an empty array, right?

 

altenbach_2-1709568233381.png

 

0 Compliments
Message 6 sur 11
768 Visites

I’m sorry to bother you. So here I made a table 1 D and I calculated the average, is that right? My problem is that I do not see by which system one can calculate the averages of the rows of a table 2 D.

Capture d'écran 2024-03-04 174227.png

0 Compliments
Message 7 sur 11
761 Visites

That still makes no sense!

The array terminal should only be inside the loop if you expect the values to change during the loop iterations. They probably don't. Why burden the compiler to generate code to check the array with every iteration?

The FOR loop is completely pointless, because it just repeats exactly the same operation four time and "Array 2" (I am sure you could define a better label!) will have four identical elements.

 

Look at my earlier code. All you need is remove the inner loop and instead autoindex on the 2D array to get one row at a time. Don't wire N!

0 Compliments
Message 8 sur 11
746 Visites

Here’s my program:
I identify myself (without a real username and password)
I put my notes in the chart and it calculates my averages if my average is more than 10 a green light appearsCapture d'écran 2024-03-04 200506.png

 

thank you so much for helping me

0 Compliments
Message 9 sur 11
739 Visites

This is still just a truncated picture, not "code" and make absolutely no sense.

 

You should not need a sequence structure, a greedy loop that burns all CPU, or dynamic data. none of this should be there!

Why do you need two empty string constants or four "10" diagram constants? Why not use this function? Why do you need two LEDs that show the opposite, but don't show valid data until the while loop has completed? Why do you have all that duplicate code instead of using a FOR loop?

Why do your 1D array have different container size? Why not resize the container to show all elements? Are all arrays the same size?

0 Compliments
Message 10 sur 11
734 Visites