Having hard time plotting groups
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mary Johnson
am 8 Okt. 2020
Bearbeitet: Mary Johnson
am 10 Okt. 2020
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 Kommentare
Seth Furman
am 9 Okt. 2020
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);

Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Power Converters finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

