MATLAB: Hi . i have n observation z1 , z2, z3 , …… zn that is numerical value and not ordered . i need partion it to interval as following

hi

z1,z2,...,zn % known data
a=min(z)
b=max(z)
k =3.322*log(n) %such that k number of interval
L= (max(z)-min(z))/k %such that L is length of each interval
i need the program display interval as following
u1=(a,a+L)
u2=(a+L,a+2*L)
.
.
.
uend=( a+end*L,b)

Best Answer

Another way is to use linspace():
n = 50;
z = 1000 * rand(1, n); % Sample data
a=min(z)
b=max(z)
k =3.322*log(n) % such that k is the number of intervals
L= (max(z)-min(z))/k %such that L is length of each interval
% Here is my solution:
intK = round(k)
uMatrix = [linspace(a, b-L, intK)', linspace(a+L, b, intK)']