how can i put a horizental bar on a plot?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have starting and ending indexes. I atteched these indexes in that files. I also have a plot. I want to put a horizental bar between vertical lines. Can you help me? It is my code
Sound=structWheeze(1,1).SoundData;
starting=structWheeze(1,1).Properties.WS_new;
ending=structWheeze(1,1).Properties.WE_new;
x = linspace(0, 144000 , 144000);
figure
plot(x,Sound)
hold on
plot(x(starting[1 1]).',(ones(size(starting,1),2).ylim).', 'g', 'LineWidth',2); %green markers
plot(x(ending[1 1]).', (ones(size(ending,1),2).ylim).', 'r', 'LineWidth',2); %red markers
hold off
grid
댓글 수: 0
채택된 답변
Star Strider
2021년 5월 31일
We do not have the plot of the signal, however drawing the horizontal lines between the starting green lines and the ending red lines is straightforward.
WS_new_array = [1063; 17565; 21359; 36899; 55411; 70245; 90088; 102232; 114892; 119569; 123811];
WE_new_array = [7952; 19385; 26744; 45315; 61905; 77760; 94105; 111387; 117453; 122765; 126968];
figure
plot((WS_new_array*[1 1]).', (ones(size(WS_new_array))*ylim).', 'g')
hold on
plot((WE_new_array*[1 1]).', (ones(size(WE_new_array))*ylim).', 'r')
plot([WS_new_array WE_new_array], [1 1]*0.8, '-k', 'LineWidth',2)
hold off
grid
I plotted them at a y-value of 0.8 here, as solid balck lines with a line width of 2. Change those to whatever value you want.
.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!