le 03-03-2024 07:19 AM
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.
Résolu ! Accéder à la solution.
03-03-2024 10:40 AM - modifié 03-03-2024 12:34 PM
Try maybe something like this?
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:
And if you want to do the sum in a shift register, here's how that would look like:
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.
le 03-04-2024 08:25 AM
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!
le 03-04-2024 09:33 AM
What have you tried and where did you get stuck? Be specific!
le 03-04-2024 09:48 AM
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
le 03-04-2024 10:10 AM
@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
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).
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?
le 03-04-2024 10:47 AM
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.
le 03-04-2024 11:49 AM
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!
le 03-04-2024 01:08 PM
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 appears
thank you so much for helping me
le 03-04-2024 01:32 PM
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?