取消
显示结果 
搜索替代 
您的意思是: 

averages in an array

Hi,
 
I would like to do an average.
Now, I read some values (voltage) and I put them in an array. I read the values N times, and I add the old values with the new ones.
At the end, I divide by N all values. The average is done.
 
My problem is that I write the new values  (N) after the N-1 reading. My program did not remplace old values by the addition.
How can I specifie that I want to start to write the new values at index 0 of the array of new values.
 
Thanks fo your helping.
 
BD.
~ La programmeuse compile le C. ~
http://www.pmeonline.fr.st
http://www.nihon-fr.com
http://www.cinemasie.com
http://ippai.free.fr
0 项奖励
1 条消息(共 10 条)
3,698 次查看
How are you building the array? What do you mean by "after the N-1 reading..". If you post your code or a picture of the block diagram it would help.
Andrew Alford
Production Test Engineering Technologist
Sustainable Energy Technologies
www.sustainableenergy.com
2 条消息(共 10 条)
3,688 次查看
barrette_new is the array of new values
I read the element at the index i of the two array. I add this two elements, and I remplace the value of the array barrette_old with this new value.
I repeat this loop N times.
Here, the elements of barrette_new are added at the end of barretete_old, and I have, at the end of the program the N array of barrette_new in barrete_old.
 
 
Thanks,
 
BD.
 
~ La programmeuse compile le C. ~
http://www.pmeonline.fr.st
http://www.nihon-fr.com
http://www.cinemasie.com
http://ippai.free.fr
0 项奖励
3 条消息(共 10 条)
3,681 次查看

There is no picture. If you clicked the Insert an Image button and your image was on your local pc, unless your pc is a public web site, that won't work. Use the attachment button below instead.

Instead of adding individual array elements and then doing a divide, just build the array and use the Mean function on the Analyze><athematics>Probablility and Statistics palette.

4 条消息(共 10 条)
3,678 次查看
Sorry for this mistake 😞 I did nt see the attachement buton o_O.
 
BD.
~ La programmeuse compile le C. ~
http://www.pmeonline.fr.st
http://www.nihon-fr.com
http://www.cinemasie.com
http://ippai.free.fr
0 项奖励
5 条消息(共 10 条)
3,673 次查看
Why are you using so many local variables? If you're going to use a for loop for anything, a shift register should be used and you should also use the auto indexing feature of a or loop instead of the Index Array functions. Every time you use a local variable, you make a copy of the data and that's not effecient.
6 条消息(共 10 条)
3,657 次查看
Do you need to use a loop?  The arithmetic operators are polymorphic and they do take arrays as inputs.  In addition, LabVIEW includes VIs do simple things like an average (not to mention complex things like non-linear minimization).  Do a search for average and you will find a couple of options (depending on what version of LabVIEW you are using).
7 条消息(共 10 条)
3,618 次查看

hi,

I will try your both solutions, and tell you if I resolv my problem.

tanks,

BD.

~ La programmeuse compile le C. ~
http://www.pmeonline.fr.st
http://www.nihon-fr.com
http://www.cinemasie.com
http://ippai.free.fr
0 项奖励
8 条消息(共 10 条)
3,592 次查看

I reduce the number of local variables and I use a register shift, but it did not works, where is my mistake?

I send you the picture of my code: I would like to do an average of AVERAGES (local variable) times with a signal I acquire with DAQ card. After treatment, I got an array: BARRETTE_NEW. I add all values with an other array: BARRETTE_OLD. I do this operation AVERAGES times.

BARRETTE_NEW and BARRETTE_OLD are initialized to 0.

Did I use coorectly the shift register?
Thanks,
 
BD.
~ La programmeuse compile le C. ~
http://www.pmeonline.fr.st
http://www.nihon-fr.com
http://www.cinemasie.com
http://ippai.free.fr
0 项奖励
9 条消息(共 10 条)
3,572 次查看

Hi, I solved my problem. Thanks very much for your helpful answers.

BD

~ La programmeuse compile le C. ~
http://www.pmeonline.fr.st
http://www.nihon-fr.com
http://www.cinemasie.com
http://ippai.free.fr
0 项奖励
10 条消息(共 10 条)
3,558 次查看