How can i plot sections of a horizontal line?
9 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
i want to recreate the third section of the graph down below. As an input i have multiple measurements over time. This you can see in the two top sections. If one of the measurements is over a limit value a event is detected and should be shown in the bottom section. For example the acceleration in green is 4, the event starts and when it drops below 4 the event stops. For time the acceleration is over the 4, a gray bar should be shown in the bottom section. Does anyone has an idea how i can do that?

Thank you in advance for you help.
Regards,
Nick
0 个评论
采纳的回答
Star Strider
2023-7-18
One approach —
t = linspace(0, 15, 150);
v = ones(size(t));
G{1} = (t >=3 & t<=4);
G{2} = (t>=14 & t<=15);
K{3} = (t>=7 & t<=12);
K{2} = (t >= 1 & t<= 6.5);
K{1} = (t >= 7.5 & t <=14.5);
figure
plot(t(G{1}), v(G{1})*3, 'Color',[1 1 1]*0.8, 'LineWidth',5)
hold on
plot(t(G{2}), v(G{2})*2, 'Color',[1 1 1]*0.8, 'LineWidth',5)
for k = 1:numel(K)
plot(t(K{k}), v(K{k})*k, 'k', 'LineWidth',5)
end
yline([1 2 3], ':k')
hold off
yticks(1:3)
yticklabels({'BM','VM','KF'})
ylim([0 4])
.
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!