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

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Mean averaging separate rows using a certain section of each row.

Asked by Tom on 24 May 2012

I need to taken a mean average of a certain section of a row of a vector - and I need to do that for every row - giving each row's mean average.

What I have is a <300000x17> vector and when the 17 rows are plotted separately they all level off at there own approximate value - maybe by about 40% along the x-axis. Right at the very right hand edge the values seem to do a weird peak so I want to avoid the very end too.

At the end of this I'd hopefully be left with 17 values only.

Any help would be much appreciated as always!

1 Comment

Matt Fig on 2 Nov 2012

I need to taken a mean average of a certain section of a row of a vector - and I need to do that for every row - giving each row's mean average.

What I have is a 300000x17 vector and when the 17 rows are plotted separately they all level off at there own approximate value - maybe by about 40% along the x-axis. Right at the very right hand edge the values seem to do a weird peak so I want to avoid the very end too.

At the end of this I'd hopefully be left with 17 values only.

Any help would be much appreciated as always!

Tom

Products

1 Answer

Answer by Honglei Chen on 24 May 2012
Accepted answer

Hi Tom, your example has 17 columns, not 17 rows. I'll assume you mean a 17x300000 matrix. It's not clear if the region for every row is the same, but I'll assume you want to take first 40% of each row, i.e., 120000 points. You can do the following:

mu = mean(x(:,1:120000),2)

This should be a good starting point.

3 Comments

Tom on 24 May 2012

Hi Honglei, thanks again for the answers. It's actually 17 columns. I tried using the x=x(:) to switch it around but it didn't work. Do you think you could let me know how to do it's 300000x17? Thanks.

Honglei Chen on 25 May 2012

Then you just need to switch the dimensions

mu = mean(x(1:120000,:),1)

You actually don't need that 1 in the end as the first dimension is the default dimension. I included it anyway to show the parallelism among the syntax.

Tom on 26 May 2012

That's great thanks Honlgei - I got it working well in the end. :)

Honglei Chen

Contact us