Sort an array logical like a stair
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone,
I got a simple problem and I thought maybe there is already a function in MATLAB I could use. I got an array like in the picture and I want to sort the values like the route from the red line.
At the end I want a 1xN array.
Do somebody know how to sort them easily like this ?
Thanks!
<<
![](/matlabcentral/answers/uploaded_files/134409/Array_sort_redline.png)
>>
2 Commenti
Jan
il 1 Ott 2018
There are 3 red lines, therefore it is not uniquely clear, what you want as output. Is it wanted, that on the right middle part, the 0.6286 is not included, but the NaN above is?
Risposte (3)
Bruno Luong
il 1 Ott 2018
If you have Image Proc TBX, you can use
watershed
regionprops
on the logical array
isnan(A)
2 Commenti
Bruno Luong
il 1 Ott 2018
No, just don't quite understand how you can get a stair boundaries in general, and why there is no branch. So I give you a generic tool that handle all situations.
Benutzer Name
il 2 Ott 2018
4 Commenti
Stephen23
il 2 Ott 2018
" In my array you can see the following path (at least a human)"
But we need an algorithm, if you want this written in any kind of code.
Bruno Luong
il 2 Ott 2018
"This is how:"
Good luck for you to find someone who can solve your human problem.
Vedere anche
Categorie
Scopri di più su Matrices and Arrays 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!