Plotting random numbers in histogram and bin allocation.

Hi all
i have a set of 100 random numbers from 0-1, i need to plot these on a histogram and allocate them to 10 bins.
the program also needs to calculate mean and standard deviation.
i am unsure on how to do this on matlab and any help would be much appreciated.
here is the random number code i have currently.
Thanks !
clear all
clc
n = 100; % However many numbers you want.
randomNumbers = randi([0, 1], [1, n])
randomNumbers = int32(randi([0, 1], [1, n]));

 채택된 답변

KSSV
KSSV 2021년 9월 5일

0 개 추천

You have striaght away functions to achieve what you want. Read about histogram, mean, std.

댓글 수: 4

ive looked at it i still cant work out how to apply it to this data
You have randomNumbers as only 0 and 1. So you will get only two bins.
x = rand(1,100) ;
histogram(x)
Thanks @KSSV, if i wanted to change the range of this. say from 0-50 now how would i do so and then alter the amount of bins?
youre help is much appreciated.
a = 0;
b = 50;
x = (b-a).*rand(1000,1) + a;
histogram(x)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 9월 5일

댓글:

2021년 9월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by