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));
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733999/image.jpeg)
3 个评论
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.
Walter Roberson
2021-9-10
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
回答(1 个)
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.
.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!