How to interpolate the local peak elevation to obtain the profile ?
2 次查看(过去 30 天)
显示 更早的评论
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.
回答(1 个)
Star Strider
2022-6-16
One option is the envelope function. Choose the 'peak' option and an appropriate value for the window length.
14 个评论
Lyhour Chhay
2022-6-16
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
2022-6-16
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
2022-6-16
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
2022-6-16
Use the ‘locs’ output to index into the appropriate vectors:
xpoints = x(locs);
ypoints = y(locs);
.
Lyhour Chhay
2022-6-16
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
2022-6-16
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
2022-6-16
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
2022-6-16
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
2022-6-16
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
2022-6-16
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
2022-6-16
My pleasure!
No inconvenience at all!
I saw that post, however I have no idea how to help you with it.
Lyhour Chhay
2022-6-16
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)