You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to interpolate the local peak elevation to obtain the profile ?
1 view (last 30 days)
Show older comments
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.
Answers (1)
Star Strider
on 16 Jun 2022
One option is the envelope function. Choose the 'peak' option and an appropriate value for the window length.
14 Comments
Lyhour Chhay
on 16 Jun 2022
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,
Star Strider
on 16 Jun 2022
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).
You will have to experiment.
Lyhour Chhay
on 16 Jun 2022
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
Star Strider
on 16 Jun 2022
Use the ‘locs’ output to index into the appropriate vectors:
xpoints = x(locs);
ypoints = y(locs);
.
Lyhour Chhay
on 16 Jun 2022
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'
Star Strider
on 16 Jun 2022
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.
Lyhour Chhay
on 16 Jun 2022
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 ?
Star Strider
on 16 Jun 2022
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.
Star Strider
on 16 Jun 2022
That depends on what you want to do.
I would just connect the ‘xpoints’ and ‘ypoints’ values with a line and enjoy the result.
Lyhour Chhay
on 16 Jun 2022
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
Star Strider
on 16 Jun 2022
My pleasure!
No inconvenience at all!
I saw that post, however I have no idea how to help you with it.
Lyhour Chhay
on 16 Jun 2022
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)