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!