GNU Octave:如何计算一组信号的上下包络?

GNU Octave: How to Compute the Upper and Lower Envelope of a Set of Signals?

我有一组信号(傅立叶级数产生了不同的正弦和余弦参数),我想找到这组信号的上下包络。

傅立叶级数的一个可行例子是:

%interval length and number of points
L = 2*pi;
N = 60;
%data points
x = (linspace(0,L,N+1))';
s1 = 1*sin(x) + 2*cos(x) + 3*sin(2*x) + 4*cos(2*x);
s2 = 4*sin(x) + 1*cos(x) + 2*sin(2*x) + 3*cos(2*x);
s3 = 3*sin(x) + 4*cos(x) + 1*sin(2*x) + 2*cos(2*x);
#
clf;
plot(x, s1, 'k', x, s2, 'b',  x, s3, 'r' )
#

如何计算我需要的信封?

感谢@Tasos Papastylianou,我找到了解决方案。将信号值排列在矩阵中并为每一行取最小值和最大值就足够了:

#To find envelope: arrange the function values in  matrix
#And take max and min by row
foo = [s1, s2, s3];
env_hi = max(foo,[], 2);
env_low = min(foo, [], 2);
#
clf;
hold on;
plot(x, s1, 'g', x, s2, 'b',  x, s3, 'r' )
plot(x, env_low, 'k^', x, env_hi, 'kv')
legend('s1', 's2', 's3', 'env-low', 'env-hi', 'location', 'north');
#