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

1 Ansicht (letzte 30 Tage)
mohammed elmenshawy am 14 Aug. 2016
Kommentiert: Image Analyst am 15 Aug. 2016
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)
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Image Analyst am 14 Aug. 2016
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)']
##### 2 KommentareKeine anzeigenKeine ausblenden
mohammed elmenshawy am 15 Aug. 2016
thank u very much , i need getting the average for this interval
Image Analyst am 15 Aug. 2016
The average what ? The average interval length is L. What else is there to take the average of ?

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Azzi Abdelmalek am 14 Aug. 2016
Bearbeitet: Azzi Abdelmalek am 14 Aug. 2016
Edit
a=min(z)
b=max(z)
k =3.322*log(n) %such that k number of interval
L= (max(z)-min(z))/k
m=fix((b-a)/L)
out=[cell2mat(arrayfun(@(x) [a+x*L,a+(x+1)*L],(0:m-1)','un',0));a+m*L,b]
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
mohammed elmenshawy am 15 Aug. 2016
thank u very much , i need getting the average for this interval

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu NaNs 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!

Translated by