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.

The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: CLAD2017 - Answer the Requirement - Average that data

SercoSteveB
Active Participant

You are tasked to write a VI?

INPUT(s): 2D Array (2D Samples Array) of DBL precision numerical values.

OUTPUT(s): 2D Array (Numeric Array Out) of DBL precision numerical values.

FUNCTION:  The VI must calculate an average value for each column of 2D Samples Array and append that average to the bottom of the column.

 

NOTE:  An example 2D Samples Array and resultant Numeric Array Out are shown below.

 

Average Channel Data Input.png

Average Channel Data Output.png

 

Have a go at writing a VI yourself or expand the Spoiler tag to see the possible solutions.

 

Spoiler

a)

Average Channel Data 1.png

b)

Average Channel Data 2.png

c)

Average Channel Data 3.png

d)

Average Channel Data 4.png

Comments
Bcortes
NI Employee (retired)

I created the following VI that performs successfully the required operation, I hoped it to be the most efficient way. I think that my code is an viable option so I will leave it here.  Regards.

 

Daily CLAD 18 Feb 2018.png

SPK91
Member

D

Priya16
Member

D

AUlikyan_ANEL
Member

D

Baltur
Member

D)

nik35324
Member

D

crossrulz
Knight of NI

D was exactly what I would have done.

 

Bcortes, the Mean.vi has a lot of optimizations in that DLL function it uses.  So from my last set of benchmarks (admittedly it has been a few years), the Mean.vi will be more efficient than writing your own code to calculate the average.  It also is more accurate when dealing with very small and very large numbers (yes, the method to compute the average affects the accuracy in these situations).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
crossrulz
Knight of NI

@SercoSteveB wrote:

You are tasked to write a VI?

 

A question?  Are you just surprised some of us are tasked with such important code?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
SercoSteveB
Active Participant

Smiley Very Happy I would say the coding foundation is the most important.

 

BTW I am no longer surprised by the things people ask me to do.

Bcortes
NI Employee (retired)

 

crossrulz
Knight of NI

Mathematics->Probability & Statistics


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
A.Bernau
Member

D

alexderjuengere
Active Participant

It appears D is supposed to be the optimal answear,

 

but I would have gone for the B-like approach

 

avg.png

 

 

simonj69
Member

D

mini09
Active Participant

D

Al_Niz
Member

why not B ??

when running the following block diagram

b).png

I got this:

 

image.png

 

isn't B) better than D)?

my thought was instead of always executing the build an array block in a loop its better to call it once outside

crossrulz
Knight of NI

Al_Niz, your diagram does not match B.  Look closely at the wire going to the top input of the Build Array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Al_Niz
Member

Smiley Surprised right i haven't seen it. thx

levonsg
Member

D

https://images.youracclaim.com/size/340x340/images/2edb5b1a-9414-44e1-8519-c774fc6dd079/36015_Certificate_Badges_FINAL__1__NI_Instructor_v5.png
istan0227
Member

D