필터 지우기
필터 지우기

extract a section of a vector and plot

조회 수: 3 (최근 30일)
Kcire L
Kcire L 2022년 9월 14일
편집: Kcire L 2022년 9월 14일
This is most likely a very trivial question but I am having difficulty getting the outcome I would like.
I have created a time vecotr based off of a sample rate I am using called t.
I have a vector called medfiltVoltage where I have found the valleys (inverse of peaks) of this vector and stored the locations of the valleys in an another vector called vv.
I would like to plot the section of medfiltVoltage from the first valley to the second valled (v(1:2)) with respect to time t.
my first thought would be this... but it is not working at all.
plot(t(vv(1:2)), medfiltVoltage(t(vv(1:2))))
however, I get this error... medfiltVoltage(1.2402): subscripts must be either integers 1 to (2^63)-1 or logicals
what am I doing wrong?
Thanks for any help on this topic.

채택된 답변

Star Strider
Star Strider 2022년 9월 14일
Perhaps something like this —
t = linspace(0, 10, 250);
s = sin(2*pi*t);
figure
plot(t,s)
grid
[pks,locs] = findpeaks(-s);
tl = t(locs);
figure
plot(t(locs(1):locs(2)), s(locs(1):locs(2)))
grid
Make appropriate adjustments to use this idea with your data.
.

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by