How do I resample my data?

3 views (last 30 days)
Veerle Kohlen
Veerle Kohlen on 7 Jan 2021
Commented: Veerle Kohlen on 8 Jan 2021
Hi,
I am looking for a method to standardise exercise duration. I measured core temperature during 60 minutes of exercise. However, due to exhaustion not all participants were able to complete the experiment. For those participants I want to resample the data, so that all participants have an equal sample number in the exercise phase. I have tried interp1, which works. However, I want to interpolate inbetween the temperatures I measured. So that the final temperature I measured, stays the final temperature measurement.
Does anyone have suggestions?
Cheers!

Accepted Answer

Image Analyst
Image Analyst on 7 Jan 2021
If the final time point in your query x (time) vector is the same, then the final temperature will be the same. If it's not, then attach your data and code to prove otherwise.
  3 Comments
Image Analyst
Image Analyst on 7 Jan 2021
I think you're looking for something like this, where the original data has 51 samples, but the resampled data has 60 samples, and the first and last points are the same.
s1 = load('nw2_temperature.mat')
s2 = load('nw2_time.mat')
% Get vectors from the mat files.
esophageal.nw2.Exercise.Temperature = s1.T;
times = s2.T;
% Put temperatures into a variable called "V".
V = esophageal.nw2.Exercise.Temperature;
V = V(:); % Convert to column vector.
% Get time vector starting at 0 instead of whatever they really start with.
times = times - times(1);
plot(times, V, 'b.-');
grid on;
hold on;
% Make 60 query times between 0 and the final time.
tQuery = linspace(times(1), times(end), 60);
y = interp1(times, esophageal.nw2.Exercise.Temperature, tQuery, 'spline');
plot(tQuery, y, 'r.-');
legend('V', 'y', 'location', 'north');

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!