LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I average the rows of and array quickly, without loops?

I decided to use MathScript, which unlike Mathlab, seems only to work on 1D arrays so I still need a loop as shown below.

 

Does any one know how to improve this with or without mathscript code?

 

Does anyone know where I can find a good list and description of MathScript commands?

 

B=Array(:,1)
rows=numel(B)
A=Array(1,:)
cols=numel(A)
for J=1:1:cols
Averaged(J)=sum(Array(:,J))/rows
end

 

Array is a 2D array passed to the MathScript node, Averaged is the average of all rows of Array.

0 Kudos
Message 1 of 4
(2,779 Views)

Hi AHF,

you can use LabVIEW functions.

See the attached image.

 

Mike

0 Kudos
Message 2 of 4
(2,772 Views)

Just do that

 

 

0 Kudos
Message 3 of 4
(2,746 Views)

Mike's example can be simplified to this:

 


AHF wrote:

Does anyone know where I can find a good list and description of MathScript commands?


The LabVIEW Help. From the Index tab, Mathscript->classes of functions.

Message Edited by smercurio_fc on 02-25-2009 09:04 AM
0 Kudos
Message 4 of 4
(2,715 Views)