From: fab Fabritius on
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
From: Sean on
"fab Fabritius" <tanelifabritius(a)yahoo.com> wrote in message <hvq640$8jm$1(a)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