How do I only highlight the decreasing portion of the green in the plot with the find function?
2 views (last 30 days)
Show older comments
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 Comments
Rik
on 10 Sep 2021
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.
Walter Roberson
on 10 Sep 2021
Effectively the same question as https://www.mathworks.com/matlabcentral/answers/1449734-how-do-i-find-the-first-30-percent-of-each-period-of-cosine?s_tid=srchtitle
Answers (1)
Star Strider
on 9 Sep 2021
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.
.
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!