필터 지우기
필터 지우기

Highlighting different part of graph

조회 수: 15 (최근 30일)
Sebastian Daneli
Sebastian Daneli 2021년 8월 24일
답변: Star Strider 2021년 8월 24일
I have this graph, represented as a vector
I am analyzing this signol for regions of interest, and I'm saving these positions as another vector. Let's say I get a vector such as
V=[1,...,10, 20,...25, 70,...,124]
(never mind why those regions are interesting, just an example). How do i highlight these regions in my graph in an easy way, i.e., so i can get something like
(again, never mind where those regions actually are). I've tried something like
figure()
hold on
plot(signal)
plot(V,signal(V),'r','LineWidth',1.5)
But I only end up with
I have ideas on how to solve this by spliting the vector and saving as a cell, but I'm wondering if anyone else has a simpler solution.

답변 (1개)

Star Strider
Star Strider 2021년 8월 24일
The likely solution is to add an independent variable vector:
x = 0:numel(signal)-1; % Independent Variable Vector
figure()
hold on
plot(x, signal)
plot(x(V) ,signal(V),'r','LineWidth',1.5)
.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by