How do I create a stacked bar graph from values in a structured array?

If I have a structured array
patient.percentages = { [02 08 09]; [23 20 24]; [] }
and I want to create a stacked bar graph (with each bar having three sections like in the []), how do I draw upon these elements in my bar code?
figure; bar(1:3, [percentages], 0.5, 'stack'); ?

 採用された回答

per isakson
per isakson 2014 年 2 月 28 日
編集済み: per isakson 2014 年 2 月 28 日

1 投票

Try
figure;
bar(1:3, cat(1,patient.percentages{:}), 0.5, 'stack');

4 件のコメント

Golnar
Golnar 2014 年 2 月 28 日
Thank you.
It gives me this error (referring also to a bar.m file I didn't know existed):
Error in bar (line 54) [msg,x,y] = xychk(args{1:nargs},'plot');
Error in clinicalreport (line 195) bar(1:3, patient.percentages{:}, 0.5, 'stack');
per isakson
per isakson 2014 年 2 月 28 日
Yes, but I corrected the error a couple of minutes after I submitted. Note the function cat, which I added.
Golnar
Golnar 2014 年 2 月 28 日
Thank you!
ROMIL
ROMIL 2014 年 2 月 28 日
That was of great help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2014 年 2 月 28 日

コメント済み:

2014 年 2 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by