Hi,
I have a problem with function envelope. It worked for all my set of data but, in one case, it didn't. When a function become constant, the envelope "goes away", creating a sort of asymptote. Or better, I think that it works, but when the function become constant I have to change stategy or stop the envelope.
I put there a right plot, without envelope, and the plot in which I get this problem.
I use this code, for example:
[low_dMRe, up_dMRe] = envelope(Int_dMRe_20,3000,'peak');
Could anyone help me, please?
Thank you in advance
Chiara

댓글 수: 3

Mathieu NOE
Mathieu NOE 2022년 7월 15일
hello Chiara
can you share some code + data ?
all the best
Mathieu NOE
Mathieu NOE 2022년 7월 15일
hello again
maybe this FEX submission is worth a look / trial :
Chiara Gigoli
Chiara Gigoli 2022년 7월 15일
Hi,
thank you very much for your answer.
Unfortunately, it doesn't work with my data...
But Star Strider gave me an helpful suggestion!
By the way, thank you a lot to give me this advice: it could be worth in other cases! :)
Chiara

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2022년 7월 15일

0 개 추천

The transition in the signal baselline is confusing envelope. It may be necessary to change the ‘np’ value, possibly to a lower number. I can reproduce the behaviour you’re seeing with different values, however with other values it comes close to behaving as expected. It will probably be necessary to just eliminate the envelope value above a specific time.
x = linspace(0, 10, 500);
y = exp(-1.25*x) .* sin(2*pi*x*4.5) + (1-exp(-0.5*x));
[envhi,envlo] = envelope(y, 46, 'peak');
figure
plot(x, y)
hold on
patch([x flip(x)], [envhi flip(envlo)], 'g', 'FaceAlpha',0.5, 'EdgeColor','none')
hold off
grid
title('Original')
ylim([-1 1.5])
Lv = envlo < y; % Plot 'envelope' Only When 'envlo' Is Less Than The Signal
figure
plot(x, y)
hold on
% plot(x, envhi, '-r')
patch([x(Lv) flip(x(Lv))], [envhi(Lv) flip(envlo(Lv))], 'g', 'FaceAlpha',0.5, 'EdgeColor','none')
hold off
grid
title('Limited')
ylim([-1 1.5])
Something like this should also work for your signal.
.

댓글 수: 5

Chiara Gigoli
Chiara Gigoli 2022년 7월 15일
Thank you a lot, it works!
That solve my question.
Chiara
Chiara Gigoli
Chiara Gigoli 2022년 7월 15일
Just one more question: I tried to plot the extreme value with a dashed line, but it doesn't work. I mean, the filling color and the envelope is right, but I can't plot the envelope boundary.
Could you give me some suggestion, please?
Chiara
As always, my pleasure!
If you are using code similar to what I posted, try this —
x = linspace(0, 10, 500);
y = exp(-1.25*x) .* sin(2*pi*x*4.5) + (1-exp(-0.5*x));
[envhi,envlo] = envelope(y, 46, 'peak');
Lv = envlo < y; % Plot 'envelope' Only When 'envlo' Is Less Than The Signal
figure
plot(x, y)
hold on
% plot(x, envhi, '-r')
patch([x(Lv) flip(x(Lv))], [envhi(Lv) flip(envlo(Lv))], 'g', 'FaceAlpha',0.2, 'EdgeColor','none')
plot(x(Lv),envhi(Lv), '--g', 'LineWidth',1)
plot(x(Lv),envlo(Lv), '--g', 'LineWidth',1)
hold off
grid
title('Limited')
ylim([-1 1.5])
It is not easy to see the dashed green limit lines (use a version of the code you used to plot the original plot to plot them so they show up well), however they do exist and are plotted.
.
Chiara Gigoli
Chiara Gigoli 2022년 7월 15일
It perfectly worked!
Thank you so so much!
Chiara Gigoli
Star Strider
Star Strider 2022년 7월 15일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

릴리스

R2022a

질문:

2022년 7월 15일

댓글:

2022년 7월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by