How to interpolate the local peak elevation to obtain the profile ?

Excuse me everyone. I have the peak point location in the figure attachement. I want to interpolate each peak point to get the profile as in the red color in the figure. How can I solve this problem ? Thank you very much.

Respuestas (1)

Star Strider
Star Strider el 16 de Jun. de 2022
One option is the envelope function. Choose the 'peak' option and an appropriate value for the window length.

14 comentarios

Dear sir,
Thank you very much for response. I appreciate your answer very much. The envelop function seem like work fine or the solution. However, I am still doubt about '[yupper,ylower] = envelope(x,np,'peak')'
The 'np' value is highly affected to the curve. I don't know how should I choose the value of np. In the figure below, I randomly the np value 10000 and it show the result like that. Actually, I want the curve in the red color. How to solve this problem sir ?
Best Regards,
I doubt that the envelope funciton can do any better than that with other ‘np’ values.
One option I can think of to get that result is to use findpeaks with 'MinPeakHeight' and 'MinPeakDistance' and then just connect the results (using the ‘locs’ output to index into the data).
Another option might simply be movmax with an appropriate window length.
You will have to experiment.
Dear Sir,
Thank you very much for your suggestion. I still doubt about your first suggestion. After I get the 'locs' from 'findpekas' fuction, How to connect the output into data ? do you mean put the locs into 'np' value ? for the 'np' value it can be only scalar.
Best regards,
LYHOUR
Use the ‘locs’ output to index into the appropriate vectors:
xpoints = x(locs);
ypoints = y(locs);
.
Dear sir,
here is my code:
AvgLevel = mean(z);
[peak,loc]=findpeaks(Zp,Xp,'MinPeakHeight',AvgLevel,'MinPeakDistance',0.005);
[yupper,ylower] = envelope(Zp,10000,'peak')'
when I put xpoints = x(locs);, it say 'Array indices must be positive integers or logical values'
That is because there is no ‘locs’ variable! (I was referring to the findpeaks documentation convention for the output names.)
Use ‘loc’ instead, since that’s what you named it.
Dear Sir,
Yes I understand, I changed already. However, It still error as show in the figure below.
I still not clear. After I get the xpoints, I have to put it into 'envelope(Zp,xpoints,'peak')' something like that ?
O.K. I did not initially see that you were using ‘Xp’ in your findpeaks call. If you want to use ‘loc’ as an index, remove that reference. The ‘loc’ output will then be in terms of the indices.
Thank you very much sir. After I get the index what should I do next ?
That depends on what you want to do.
I would just connect the ‘xpoints’ and ‘ypoints’ values with a line and enjoy the result.
oh I got it. Thank you very much sir for your valuable time.
Anyway, sir, I am sorry for your inconvenience. I have one more question.I have been post in the forum:
I really appreciate and thank you very much it if you could guide me to solve the problem.
Best Regards,
LYHOUR
My pleasure!
No inconvenience at all!
I saw that post, however I have no idea how to help you with it.
I really appreciated your kindness sir. Actually, I found some forum that is similar to my problem as the following link:
I also commented my problem in that post. However, I am not clearly understand the proposed algorithm. I hope that I can solve this problem.
My pleasure!

Iniciar sesión para comentar.

Preguntada:

el 16 de Jun. de 2022

Comentada:

el 16 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by