Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Taking average of specific data from a data set

Subject: Taking average of specific data from a data set

From: Mohammad

Date: 7 Feb, 2013 20:00:12

Message: 1 of 3

Data= 0.11,( -1.11, -0.75), -0.02, -0.36, (-0.97), -0.35, (-1.02, -1.33, -1.00), -0.15, (-0.66, -0.59, -1.21, -0.70), 0.06, (-1.65), 0.03, 0.25, (-1.35), -0.08,(-0.91, -0.82, -1.29), -0.26

In this data set 7 events have values less than -0.5. ( ) indicate one event, this is for better understanding, don't have in real data. My purpose is to take average of each event > sum all of this average > again divide this sum by total number of events (i.e.7).

This process will repeat for 40 data set. Thanks in advance for your help.

Badrul

Subject: Taking average of specific data from a data set

From: Jomar Bueyes

Date: 7 Feb, 2013 20:33:39

Message: 2 of 3

On Thursday, February 7, 2013 3:00:12 PM UTC-5, Mohammad wrote:
> Data= 0.11,( -1.11, -0.75), -0.02, -0.36, (-0.97), -0.35, (-1.02, -1.33, -1.00), -0.15, (-0.66, -0.59, -1.21, -0.70), 0.06, (-1.65), 0.03, 0.25, (-1.35), -0.08,(-0.91, -0.82, -1.29), -0.26
>
>
>
> In this data set 7 events have values less than -0.5. ( ) indicate one event, this is for better understanding, don't have in real data. My purpose is to take average of each event > sum all of this average > again divide this sum by total number of events (i.e.7).
>
>
>
> This process will repeat for 40 data set. Thanks in advance for your help.
>
>
>
> Badrul

Hi Badrul,

I'm not sure I fully understand your question. If you want to process only those elements greater than or equal to -0.5, you can extract them from the 'Data' array by

newData = Data(Data >= -0.5);

If you only want the sum, not to extract them, you can do that by

total = sum( Data(Data >= -0.5) );


HTH

Jomar

Subject: Taking average of specific data from a data set

From: Sadik

Date: 8 Feb, 2013 01:50:08

Message: 3 of 3

Hi Badrul,

You can do the following:

data = [0.11, -1.11, -0.75, -0.02, -0.36, -0.97, -0.35, -1.02, -1.33, -1.00, -0.15, -0.66, -0.59, -1.21, -0.70, 0.06, -1.65, 0.03, 0.25, -1.35, -0.08,-0.91, -0.82, -1.29, -0.26]
mask = data < -0.5;
L = bwlabel(mask)
r = regionprops(L,data,'mean');
eventMeans = struct2array(r)
mean(eventMeans)

Best.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us