signal-processingoctaveenvelope

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


I have a set of signals (Fourier series produced varying the sine and cosine parameters) and I would like to find the upper and lower envelope of this set.

A workable example of the Fourier series is:

%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' )
#

enter image description here

How can I compute the envelopes I need?


Solution

  • Thanks to @Tasos Papastylianou, I found a solution. It is enough to arrange the signal values in a matrix and take the minimum and maximum values for each row:

    #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');
    #
    

    enter image description here