How do I only highlight the decreasing portion of the green in the plot with the find function?

2 次查看(过去 30 天)
The green in the graph that is highlighted on the curve, i want it so it would only highlight the peak and the decreasing slope areas? How would I go about that and incorporate it if this is part of my code: section = find( ft > (8));
  3 个评论
Rik
Rik 2021-9-10
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2021-9-9
The vector in the plot image (or the code to create it) are not available, so I substituted my own.
This should get you started —
x = linspace(3, 12); % Create Data
y = sinc(x-7.5); % Create Data
[pks,locp] = findpeaks(y); % Peaks & Location Indices
[vys,locv] = findpeaks(-y); % Valleys & Location Indices
figure
plot(x, y) % Plot Original Vector
hold on
for k = 1:numel(locp)
idxrng = locp(k) : min(locv(locv>locp(k))); % Define Range Of Indices
idx(idxrng) = y(idxrng)>= 0.6; % Define Portion Of Curve
plot(x(idx), y(idx), '-g', 'LineWidth',5) % Plot Withg Highlights
end
hold off
Make appropriate changes to work with other vectors.
.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by