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:
geometric mean month by month

Subject: geometric mean month by month

From: Saad

Date: 23 May, 2013 17:56:11

Message: 1 of 2

Dear All,

I need some help please.
I have two columns in a matrix B.
B=[A, X];
X is a column vector that contains different daily observations.
A is a column vector that contains the number of the month (for example for January it has "1" for february "2" etc till December where it has "12").

Column X has daily data for January, Feb till december. Thus Column A has numbers that change according to the month number. For instance, for january, Column A will have thirty one "1" corresponding to 31 days in january and twenty nine "2" corresponding to 29 days in February until the end of the year then i will start again with january with "1" and february with "2" etc till december .

What I would like to do is to do the gemetric mean of the values of X for similar values of A. Basically, it is like if Iam doing a geometric mean month by month untill the end of my data series. How can I do that please? I am stuck in this. ANy help is much appreciated.
Best

S

Subject: geometric mean month by month

From: dpb

Date: 24 May, 2013 14:11:49

Message: 2 of 2

On 5/23/2013 12:56 PM, Saad wrote:
...
> I need some help please.
> I have two columns in a matrix B.
> B=[A, X];
> X is a column vector that contains different daily observations.
> A is a column vector that contains the number of the month (for example
> for January it has "1" for february "2" etc till December where it has
> "12").
>
...

> What I would like to do is to do the gemetric mean of the values of X
> for similar values of A. Basically, it is like if Iam doing a geometric
> mean month by month untill the end of my data series. How can I do that
> please? I am stuck in this. ANy help is much appreciated.

"Deadahead" solution...

g=zeros(12,1);
for i=1:12
   g(i)=geomean(B(B(1,:)==i,2);
end

I've only very recently received my later version of ML that has
arrayfun and such modern niceties so my fluency therein isn't yet up to
writing the above on the fly via it but that's the "neat" way...

--

Tags for 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