Sort an array logical like a stair
Show older comments
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!
<<

>>
2 Comments
Jan
on 1 Oct 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?
Benutzer Name
on 1 Oct 2018
Answers (3)
Bruno Luong
on 1 Oct 2018
If you have Image Proc TBX, you can use
watershed
regionprops
on the logical array
isnan(A)
2 Comments
Benutzer Name
on 1 Oct 2018
Bruno Luong
on 1 Oct 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
on 2 Oct 2018
0 votes
4 Comments
Bruno Luong
on 2 Oct 2018
Edited: Bruno Luong
on 2 Oct 2018
For the sake of trying to understand your goal, what would be the outcome of this example:
A =
NaN 3 NaN 7 11
NaN NaN NaN 8 NaN
1 4 NaN NaN NaN
NaN 5 NaN 9 12
2 NaN 6 10 13
Benutzer Name
on 2 Oct 2018
Stephen23
on 2 Oct 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
on 2 Oct 2018
"This is how:"
Good luck for you to find someone who can solve your human problem.
Benutzer Name
on 10 Oct 2018
Categories
Find more on Data Type Identification 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!