How to: simple stack bar

Hi
I want to stack a bar but it gives error
X as Y same lenght
i have a simple matrix,
A=[76 96 68 15 112 160]
I plot:
bar(1,A(1,1),'c')
hold on
bar(2,A(1,2),'y')
till bar 6 with each own color, bar 7 should be total of them off them but stacked and with each of them with their representative color.

 채택된 답변

the cyclist
the cyclist 2013년 2월 8일

0 개 추천

Here is one way:
A = [76 96 68 15 112 160];
A6 = nan(6,6);
A6(1:7:36) = A;
A7 = [A6;A];
bar(A7,'stacked');

댓글 수: 1

Hello kity
Hello kity 2013년 2월 8일
hmm much shorter than my code :)
thx you

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 8일
편집: Azzi Abdelmalek 2013년 2월 8일

0 개 추천

close
A=[76 96 68 15 112 160]
cl='rgbkcm'
for k=1:6
bar(k,A(k),cl(k))
hold on
end
set(gca,'xtick',1:6)

카테고리

태그

Community Treasure Hunt

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

Start Hunting!

Translated by