Fitting real data curve to a homogeneous diff

1 次查看(过去 30 天)
Hello! I measured accelerations with matlab Mobile and I encountered the problem that the time step was not homogeneous and therefore the measured frequency. Therefore, I created a homogeneous diff (blue curve) and I would like to find a code in MATLAB that adapts the measured function with the real values (red curve) to that homogeneous time increment.
I attach a picture of the problem.

采纳的回答

Star Strider
Star Strider 2023-5-16
I am not certain from your description what you want to do. However if you have the Signal Processing Toolbox, the resample function coukld be appropriate. (It is preferable to interp1 for singal processing applications.)
  8 个评论
Daniel Sánchez Muñoz
Hello!
Thanks for your help. The problem is that you use the mean frecuency, so there is still a non homogeneus sample frecuency.
I have finally solved the problem.
Pd.: Do I have to accept your answer? I thank you very much for the help.
data=[t,z];
COLTIME = 1;
COLACEL = 1;
tt = (data(:, COLTIME) - data(1, COLTIME));
v = data(:, 2:end);
% Interpolate data to assure constant time interval at fs:
dt = 1 / fs;
ntime = length(data);
tq = zeros(1,ntime);
for i = 2:ntime
tq(i) = tq(i-1) + dt;
end
vq = interp1(tt, v(:,COLACEL), tq,'spline','extrap');
% Reconstruct the data vector:
data = [tq', vq'];
Star Strider
Star Strider 2023-5-28
I would appreciate it if you would accept my answer.
I actually use the most common frequency, that I derive from the differences in the sampling intervals. I use mean, I also could have used mode.
I notice the the code you posted uses ‘fs’ to define ‘dt’ without first defining ‘fs’. I have no idea how you define ‘fs’.
I also use resample instead of interp1 because resample uses an anti-aliasing filter. This is important for signal processing applications, and signal processing is apprarently what you want to do.
The resample function also has the 'spline' option as an interpolation method. I rarely use it (preferring 'pchip') because it can give some wildly varying results.
.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by