Saturday, February 9, 2008

function in matlab to convert 1/4-h vectors to 1-h vector

sometime i have to handle with large data vectors, which are time measurements. One value each 15 Min.

For the analysis, i can use 1 value per hour. to convert the vectors i use the following function:


function DATout = convert_15min_1h(DATin)
size_15min=length(DATin);
size_1h=size_15min/4;
DATout=zeros(size_1h,1);
for i=1:1:size_1h
von=(i-1)*4+1;
bis=(i)*4;
DATout(i)=sum(DATin(von:bis))/4;
end

No comments: