Resample from a nonuniform time history while keeping the peak and valley values
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tala
el 21 de Dic. de 2020
Respondida: Image Analyst
el 22 de Dic. de 2020
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 comentarios
jessupj
el 22 de Dic. de 2020
Editada: jessupj
el 22 de Dic. de 2020
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.
Respuesta aceptada
Image Analyst
el 22 de Dic. de 2020
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);
0 comentarios
Más respuestas (1)
the cyclist
el 22 de Dic. de 2020
Editada: the cyclist
el 22 de Dic. de 2020
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.)
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!