I have two sine signal with me and I wanted to find an envelope of both the signal. Could anyone tell me how to do that?

 Réponse acceptée

Use the envelope function.
t = linspace(0, 1, 1E+3);
s = sin(2*pi*t*5) .* sin(2*pi*t*100);
[senvu,senvl] = envelope(s, 10, 'peak');
figure
plot(t, s, 'DisplayName','Signal')
hold on
plot(t, senvu, '-m', 'LineWidth',2, 'DisplayName','Upper Envelope')
plot(t, senvl, '-c', 'LineWidth',2, 'DisplayName','Lower Envelope')
hold off
grid
.

2 commentaires

vani
vani le 29 Oct 2022
Its showing error like below
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in myenvelope>envelope (line 159)
t=linespace(0,1,1E+3); (for this line)
Star Strider
Star Strider le 29 Oct 2022
This is misspelled:
t=linespace(0,1,1E+3); % (for this line)
Because of that, MATLAB does not recognise it as a function, and considers it a variable, throwing the error.
If you copy and paste my code exactly as I wrote it (perhaps using your own ‘s’ function instead), it should run without error.
.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2022a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by