필터 지우기
필터 지우기

Resample from a nonuniform time history while keeping the peak and valley values

조회 수: 9 (최근 30일)
Hi,
I have a time series with a nonuniform time vector. The attached spread sheet contains two columns. The first column (Time in seconds) ranges from 0.04 to 901 seconds. The second column is RPM. I would like to resample from this time history unifromly with time=0:0.25:900.
I used different resampling techniques using MATLAB documentation. In all of them, I lose the peak and valley values. Peak and valley values are important to me as they define the maximum and minimum wind speed.
How can I resample from this time history on a uniform time vector while I keep the peak and valley values? Is there a way to force the algorithm to choose the extremum values when the different between time values are small?
Thank you in advance :)
  댓글 수: 3
Tala
Tala 2020년 12월 22일
Thanks for responding.
Well, I am not only intesrted in the max values. This time series goes to a machine which time vector needs to be 0:0.25:900. Once I resample on this time vector, I miss the peaks
jessupj
jessupj 2020년 12월 22일
편집: jessupj 2020년 12월 22일
i'd suggest trying something like interpolation at the regular sample points via lagrange polynomials or something. i didn't look at the data, but i'm sure it would be obvious to you if your 1/4sec sampling was too coarse to resolve local extrema.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2020년 12월 22일
Did you try interp1() with the 'nearest' option. Since your peak may be between new time sample points, you will lose the peaks unless you use the 'nearest' option:
fprintf('Beginning to run %s.m ...\n', mfilename);
data = readmatrix('Mtlb.xlsx');
t = data(:, 1);
y = data(:, 2);
% Plot original data.
subplot(1, 2, 1);
plot(t, y, 'b-');
grid on;
title('Original Data', 'FontSize', 18);
xlabel('t', 'FontSize', 18);
ylabel('y', 'FontSize', 18);
xlim([0, max(t)]);
newt = 0:0.25:900;
% Imterpolate without losing peaks.
newy = interp1(t, y, newt, 'nearest');
% Plot the interpolated data.
subplot(1, 2, 2);
plot(newt, newy, 'b-');
grid on;
title('Interpolated Data', 'FontSize', 18);
xlabel('new t', 'FontSize', 18);
ylabel('new y', 'FontSize', 18);
xlim([0, max(t)]);
fprintf('Done running %s.m ...\n', mfilename);

추가 답변 (1개)

the cyclist
the cyclist 2020년 12월 22일
편집: the cyclist 2020년 12월 22일
There is almost certainly not a built-in function that does this resampling in the exact way you want. Instead, you need to think about properties of the original data you need to retain, and what you don't. So, for example, if t and rpm are your original data, then you can do a simple interpolation
t0 = 0 : 0.25 : 900;
rpm0 = interp1(t,rpm,t0);
to get rpm values at evenly spaced time points.
Then, you could just manually replace the interpolated highest and lowest values of the interpolated rpm with the known high and low.
Is that sensible? If not, you need to provide more detail about what aspects of the resampling are critical, so that we can help guide you to a solution. (It might also help if you upload the code you have tried, and explain why the result is unsatisfactory in a little more detail.)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by