graphing 2 graphs in one figure

조회 수: 3 (최근 30일)
Levan Tavdgiridze
Levan Tavdgiridze 2020년 12월 6일
댓글: Levan Tavdgiridze 2020년 12월 6일
Hello I am trying to graph 2 graphs side to side. this is my code creating both "frec" and "expectedProbabilities" bars but when I try b = bar(x,expectedProbabilities); does not work.
M = randi([0 1], 20, 2500);
M_sum = sum(M);
freq = accumarray(M_sum(:), 1, [20 1]);
figure(1);
bar(1:20, freq);
xlabel('Number of ones');
xlabel('Number of rows');
expectedProbabilities = zeros(20,1);
for i = 0:20
expectedProbabilities(i+1,1) = factorial(20)/(factorial(i)*factorial(20-i))*0.5^i*0.5^(20-i)*2500;
end
figure(2);
bar(expectedProbabilities);

채택된 답변

Xavier Croes
Xavier Croes 2020년 12월 6일
combined = [freq, expectedProbabilities(1:20)];
b = bar(combined, 'grouped')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Bar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by