Having hard time plotting groups

6 次查看(过去 30 天)
I have two sets of group(each group 3 column). I have the mean for each column. I wanted to plot both groups on one graph but i am having hard time understanding the best code to use to get the graph. I am really new to Matlab and would appreciate the help.
  11 个评论
Mary Johnson
Mary Johnson 2020-10-9
编辑:Mary Johnson 2020-10-9
@Seth Furman, I am wanting the X axis to be the 6 conditions and i want the Y axis the be the mean values. I am wanting the TEST 1(Group A-C) and TEST 2(GroupD-F) both to be on the blot. YES i want to adjust plots. Yes i want to average A through C and D through F. The first plot is supposed to have (condition 1 with Mean column A, condition 2 with Mean column B, condition 3 with Mean column C). The second plot is supposed to be similart to first plot but only from (D-F) in conncected line. Thank you for the help.
Seth Furman
Seth Furman 2020-10-9
Ok. So it sounds like you want something like a bar graph.
Bar graphs can be created with the "bar" function: https://www.mathworks.com/help/matlab/ref/bar.html
I've included an example of the "bar" function below. Please also check out the documentation for plotting, which you may also find helpful:
>> t = array2table(reshape(1:36,6,6),'VariableNames',strcat("Group",["A" "B" "C" "D" "E" "F"]))
t =
6×6 table
GroupA GroupB GroupC GroupD GroupE GroupF
______ ______ ______ ______ ______ ______
1 7 13 19 25 31
2 8 14 20 26 32
3 9 15 21 27 33
4 10 16 22 28 34
5 11 17 23 29 35
6 12 18 24 30 36
>> tMean = varfun(@mean,t)
tMean =
1×6 table
mean_GroupA mean_GroupB mean_GroupC mean_GroupD mean_GroupE mean_GroupF
___________ ___________ ___________ ___________ ___________ ___________
3.5 9.5 15.5 21.5 27.5 33.5
>> tiledlayout(2,1);
>> nexttile;
>> x = categorical(t.Properties.VariableNames(1:3));
>> y = tMean{:,1:3};
>> bar(x,y);
>> nexttile;
>> x = categorical(t.Properties.VariableNames(4:6));
>> y = tMean{:,4:6};
>> bar(x,y);

请先登录,再进行评论。

采纳的回答

Mary Johnson
Mary Johnson 2020-10-10
编辑:Mary Johnson 2020-10-10
@Seth Ferman, thank you soooo much!!!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Power Converters 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by