Clear Filters
Clear Filters

Filtering the data according to the time stamp

2 views (last 30 days)
I would like to filter this data according to the time stamp i.e for the first three second of the time, and take average of Elevation and Speed at 0, 1, 2 and 3 sec.
OR take average for the first three second each time, and return one mean value for each parameters.
What is the appropriate function?
Anyone expert on this?
Let say matrix of A =
Time, s Elevation Speed
0 23.9 0.28
0 23.9 0.28
0 23.9 0.28
0 23.9 0.28
1 23.9 0.28
1 23.9 0.28
1 24.7 0.28
1 24.7 0.28
1 24.7 0.28
1 24.7 0.28
2 24.7 0.28
2 24.7 0.28
2 24.7 0.44
2 24.7 0.44
3 23.1 0.44
3 23.1 0.44
3 23.1 0.44
3 23.1 0.44
3 23.1 0.44
3 23.1 0.44

Answers (1)

Kostas
Kostas on 20 Nov 2011
Sure not the most "efficient" solution but could work smt like that
k=0;
for i=0:3 % loop over the seconds
id=find(A(:,1)==i); %get indices where you find the time you want
if ~isempty(id)
k=k+1;
elev_mean=mean(A(id,2)); %mean value of parameter elevation
s_mean=mean(A(id,3)); %mean value of parameter time
m_values(k,:)=[i elev_mean s_mean];
end
end
  1 Comment
ASMS Mat Su
ASMS Mat Su on 28 Nov 2011
Thanks Kostas;
Its not working...How about this...
n = 5; % Number of filtered data
t = max (A(:,1)); % max total Time,s
k=1;
for i=0:t; % Loops for time t=0 to t=Max
ind = find(A(:,1)==i);
X = EC(ind(1:n),1:3);
disp (X);
Y = mean(A(ind(1:n),2:4));
k=k+1;
end
but then I have another problem! I want to get every single X stored e.g for the first 2 row at t=0,1,2,3...

Sign in to comment.

Categories

Find more on Digital and Analog Filters in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!