fprintf('Beginning to run %s.m ...\n', mfilename);
data = readmatrix('Mtlb.xlsx');
t = data(:, 1);
y = data(:, 2);
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;
newy = interp1(t, y, newt, 'nearest');
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);
3 Comments
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/699670-resample-from-a-nonuniform-time-history-while-keeping-the-peak-and-valley-values#comment_1222765
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/699670-resample-from-a-nonuniform-time-history-while-keeping-the-peak-and-valley-values#comment_1222765
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/699670-resample-from-a-nonuniform-time-history-while-keeping-the-peak-and-valley-values#comment_1222780
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/699670-resample-from-a-nonuniform-time-history-while-keeping-the-peak-and-valley-values#comment_1222780
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/699670-resample-from-a-nonuniform-time-history-while-keeping-the-peak-and-valley-values#comment_1222795
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/699670-resample-from-a-nonuniform-time-history-while-keeping-the-peak-and-valley-values#comment_1222795
Sign in to comment.