您应该创建一些公共轴,并使用插值(例如interp1)来近似所有这些点的值。然后你可以添加它们。
% Your data, but with smaller intervals so it doesn't look like junk!
t1 = 1:0.01:10; y1 = sin(t1);
t2 = 1:0.02:12; y2 = sin(2*t2);
% Interpolation to the highest number of points
N = max(numel(t1), numel(t2));
y1interp = interp1(t1, y1, linspace(min(t1), max(t1), N), 'linear');
y2interp = interp1(t2, y2, linspace(min(t2), max(t2), N), 'linear');
% Put on a common percentage axes with N points
pct = linspace(0, 1, N);
% Plot (or do whatever else!)
figure; hold on;
plot(pct, y1interp, '--r');
plot(pct, y2interp, '--b');
plot(pct, y1interp + y2interp, '-k');
hold off;
输出
注意:您可能需要阅读有关 Nyquist's theorem 的信息 - 您应该考虑将用于插值的常见样本数 N 增加到我使用的两倍。