필터 지우기
필터 지우기

Creation of a "Status Bar" plot, displaying machine statuses (ON, OFF, Standby)

조회 수: 1 (최근 30일)
Simon
Simon 2014년 6월 28일
댓글: Simon 2014년 6월 29일
Hi all,
Is there a way to create a subplot like the lower one in the picture?
I have 2 matrices for the statuses of n machines, one for the ONs, one for the standbys, S_on and S_sb. A '1' in each of those matrices represents on or standby, '0' in both mean off. To create the final matrix with the power Consumption, each of them will be multiplied with a Power vector.
Now I want to create a status bar beneath indicating when the machine is ON, standby or OFF. How do I plot this? Thank you so much for your help!
Simon

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 6월 28일
편집: Azzi Abdelmalek 2014년 6월 28일
x=[0 1 1 2 2 4 4 5 ]
y=[2 2 1 1 0 0 2 2]
subplot(211),plot(x,y)
subplot(212),
in={'off','sb','on'}
cl={'g','b','y'}
for k=1:numel(x)/2
xx=x(2*k-1:2*k )
plot([ xx fliplr(xx) xx(1)],[0 0 1 1 0],cl{y(2*k)+1},'linewidth',12)
text(mean(xx),0.5,in{y(2*k)+1},'fontsize',12)
hold on
end
hold off
  댓글 수: 1
Simon
Simon 2014년 6월 29일
Hi Azzi,
thank you for your help! I tried to alter the code to fit my question, but could not do so. How can I make the code work for a continuous x? Like x=[0 1 2 3 4 5 ...] and that for y=2 ON is displayed, y=1 sb and y=0 OFF without gaps? When I just change it in your code, I get "discrete" bars with gaps in between.
Again, thank you for your help!
Simon

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by