make interval from data points for plotting
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I want to make several continuous intervals from data points on x-axis with the same y-axis input over x-axis. You can see x data points with the same (y=1) just like the attached photo. Distance between data points should not be more than 0.1, otherwise the next point will be assigned to next interval.

x=[ -72.5171 -72.4950 -72.4729 -72.1416 -72.1195 -72.0974 -72.0753 -71.7219 -71.6998 -71.6777 -71.6556 -71.5893 -71.5672 -71.5452 -71.5231 -71.1475 -71.1254 -71.1034 -71.0813 -71.0592 -71.0371 -70.8825 -70.8604 -70.8383 -70.8162 -70.3965 -70.3744 -70.3523 -70.3302 -70.1756 -70.1535 -70.1314 -70.1093 -70.0872 -70.0651 -70.0210 -69.9989 -69.9768 -69.9547 -69.9326 -69.9105 -69.8884 -67.8783 -67.8562 -67.8341 -67.8120 -67.7899 -63.6592 -63.6371 -63.6150 -63.5929 -63.5708 -62.7314 -62
.7093 -62.6872 -62.6651 -60.3236 -60.3016 -60.2795 -60.2574 -60.2353 -58.9762 -58.9541 -58.9320 -58.9099 -53.8072 -53.7851 -53.7630 -53.7410 -53.7189 -53.6968 -53.6747 -53.6526 -53.6305 -53.6084 -53.1887 -53.1666 -53.1445 -53.1224 -52.4598 -52.4377 -52.4156 -52.3935 -52.3714 -52.3493 -52.2168 -52.1947 -52.1726 -52.1505 -52.1284 -52.0401 -52.0180 -51.9959 -51.9738 -51.7971 -51.7750 -51.7529 -51.7308 -51.7087 -51.3774 -51.3553 -51.3332 -51.3111 -51.2890 -51.2669 -51.2448 -51.2227 -51.2006 -50.6042 -50.5821 -50.5601 -50.5380 -50.5159 -50.4938 -50.4717 -50.4496]
0 Commenti
Risposta accettata
Geoff Hayes
il 10 Ott 2014
Ali - if you want to determine where the next interval should begin, you could consider the difference between each element. When the difference is greater than 0.1, you would know that that is the start of a new interval. Use the diff command for that. With your x from above, we could do
intervallStartIdcs = [1 find(diff(x)>0.1)+1];
We calculate the difference between each consecutive element using diff. We then then use find to determine the indices in that difference vector of values (differences) greater than 0.1. As the difference vector has one less element than x, we add one to each of those indices. We then prefix this vector of indices with 1 which will correspond to the first interval. In this case, we get an answer of
1
4
8
16
22
26
30
43
48
53
57
62
66
76
80
86
95
100
109
A quick glance at some of the values does show that new intervals begin at 1, 4, 8, etc. from our vector x.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!