Thread Subject:
Calculating mean values from data with NaN`s

Subject: Calculating mean values from data with NaN`s

From: fab Fabritius

Date: 22 Jun, 2010 11:17:20

Message: 1 of 2

Hi,

I`m trying to calculate mean values from data matrice C. The data matrice contains time serie in the first column and some measurment data with NaN values in the next three columns. In addition I only want to take only those times that are in the limits of certain start and finish times. I have put here an example of what I`m trying to do. I have tried applying "mean(x(find(~isnan(x))))" in the for-loop but I`m not able to make it work. I have loads of this data and they are almost 20 000 rows each, so thanks for all the hints!

close all
clear all

C=[1 rand NaN rand;2 rand rand rand;3 rand rand rand;4 rand rand rand;5 rand rand rand; 6 rand rand rand; 7 rand rand rand; 8 rand rand rand; 9 rand rand rand; 10 rand rand rand];
Start=[1 4 8]
Finish=[2 7 9]

A=Start'
B=Finish'

[m n]=size(C);

[intersection,a,b]=intersect(C(:,1),A(:,1));
[intersection,c,d]=intersect(C(:,1),B(:,1));

D(:,1)=a(:,:);
D(:,2)=c(:,:);

[mm nn]=size(D);


 for i=1:mm;
 
 Apu(i,1)=mean(C(D(i,1):D(i,2),2))
 Apu(i,2)=mean(C(D(i,1):D(i,2),3))
 Apu(i,3)=mean(C(D(i,1):D(i,2),4))
 
 end;

thanks again!
-taneli

Subject: Calculating mean values from data with NaN`s

From: Sean

Date: 22 Jun, 2010 12:32:24

Message: 2 of 2

"fab Fabritius" <tanelifabritius@yahoo.com> wrote in message <hvq640$8jm$1@fred.mathworks.com>...
> Hi,
>
> I`m trying to calculate mean values from data matrice C. The data matrice contains time serie in the first column and some measurment data with NaN values in the next three columns. In addition I only want to take only those times that are in the limits of certain start and finish times. I have put here an example of what I`m trying to do. I have tried applying "mean(x(find(~isnan(x))))" in the for-loop but I`m not able to make it work. I have loads of this data and they are almost 20 000 rows each, so thanks for all the hints!

A hint:
>>help nanmean
Good Luck

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
reference Sean de 22 Jun, 2010 08:34:07
nanmean Sean de 22 Jun, 2010 08:34:07
rssFeed for this Thread

Contact us