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

采纳的回答

Star Strider
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 个)

类别

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