Automatic border detection?

Hi I have this array:
I want to automatically border segments of these indices. Is there a way without using a threshold to let Matlab these borders automatically and maybe by itself? Some kind of automatic segment detection function? Or do you have any suggestions how to come to the shown output?
A = [1 27 31 56 58 60 91 93 122 126 153 526 538 568 616 620 623 643 651 667 673 758 767 961 991 1053 1060]
plot(A, 1, '*')
Expected Output:
A1 = [1 27 31 56 58 60 91 93 122 126 153]
A2 = [526 538 568 616 620 623 643 651 667 673]
A3 = [758 767]
A4 = [961 991 1053 1060]
Thanks!

3 commentaires

KALYAN ACHARJYA
KALYAN ACHARJYA le 3 Sep 2019
Modifié(e) : KALYAN ACHARJYA le 3 Sep 2019
How you decide the A1,A2...from A, is there any logic?
Directly
A1=A(A<154);
A2=A(A>154 & A<700)
....so on ???
JamJan
JamJan le 3 Sep 2019
That is to manual. I want Matlab to automatically identify those borders and thus segments
The question we have is what is the logic you used when determining these example segments. Will there always be only 4 segments? Will the numbers always be ordered from smallest to largest?
If the answer to both those questions is yes and the way you are separating them is the largest gaps. I would do this:
[vals, idxs] = sort(diff(A));
segBreaks = sort(idxs(end-3:end));
A1 = A(1:segBreaks(1));
A2 = A(segBreaks(1)+1:segBreaks(2));
A3 = A(segBreaks(2)+1:segBreaks(3));
A4 = A(segBreaks(3)+1:end);
If you have the classification learner app you could try to use that as well.

Connectez-vous pour commenter.

Réponses (0)

Question posée :

le 3 Sep 2019

Commenté :

le 3 Sep 2019

Community Treasure Hunt

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

Start Hunting!

Translated by