Having hard time plotting groups

조회 수: 6 (최근 30일)
Mary Johnson
Mary Johnson 2020년 10월 8일
편집: Mary Johnson 2020년 10월 10일
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