How can I determine or formulate certain intervals from a given set of data.

1 view (last 30 days)
Assuming that I have the following data.
0.110064
0.120277
8.957109
-------
-------
8.957806
-------
-------
50.69346
50.6958
50.69846
-------
-------
up to n
I want to have about 20 groups of intervals such as,
interval(1)= 0.110064 to 0.310064
interval(2)= 0.310064 to 0.510064
-------------------------
-------------------------
interval(n)= a to b
interval(n+1)= c to d
where a, b, c, d are any values within the data. Please note a<b<c<d
At the end, I want to have something like this (where the first number is extracted from the lower range of the first interval , followed by its upper range (as the second number); and the third number being the upper range of the second interval etc), as shown below.
IntervalRange(1)= 0.110064
IntervalRange(2)= 0.310064
IntervalRange(3)= 0.510064
-------------------------
-------------------------
IntervalRange(k)= n
IntervalRange(k+1)= n+1
In fact the output should only be like the one below;
*0.110064
0.310064
0.510064
n
n+1
Thank you*

Accepted Answer

Matz Johansson Bergström
Matz Johansson Bergström on 26 Jul 2014
Edited: Matz Johansson Bergström on 26 Jul 2014
If I understand it correctly, you want something like this?
%mock data, increasing numbers
data = 50*rand(50,1);
data = sort(data);
%The intervals
iv = linspace(data(1), data(end), 20)

More Answers (0)

Categories

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!