Thread Subject: Unshuffle algorithm

Subject: Unshuffle algorithm

From: Sven

Date: 4 Aug, 2007 08:35:34

Message: 1 of 3

Hi there,
I have an array of numbers made up of two sequences that
have been sorted. I am trying to find an algorithm that can
extract separate arrays made up of these sequences.

For example:
arr1 = sort([1:5 7:0.5:10]);

This first case is straight-forward, as the two sequences
don't overlap. I can get the 1st index of the two sequences
using diff:
indices = find(diff(arr1,2))+2; % +2 because a 2nd order
diff is taken.
sequence_indices = {1:indices(1)-1, indices(1):length(arr1)}

However, this technique only works if the two sequences are
non-overlapping. For example, a more difficult case is:
arr2 = sort([1:5 4.2:10]);

Can anyone point out I should tackle the problem of
extracting the two sequences in this case?

Thanks for any suggestions,
Sven.

Subject: Unshuffle algorithm

From: John D'Errico

Date: 4 Aug, 2007 12:46:58

Message: 2 of 3

"Sven " <sven.holcombe@removethis.gmail.com> wrote in message
<f91dom$3hv$1@fred.mathworks.com>...
> Hi there,
> I have an array of numbers made up of two sequences that
> have been sorted. I am trying to find an algorithm that can
> extract separate arrays made up of these sequences.
>
> For example:
> arr1 = sort([1:5 7:0.5:10]);

If I might ask, what is the source of this problem?
Its exactly the second time I've seen it come up,
the last being roughly 1.5 years ago.

This is, as I see it, a variant of clustering problem.
I can supply a code that does it, using my
consolidator tool as part of the engine. I'd not
seen a reason to post it on the file exchange the
first time it was asked.

Its a bit long to paste in here though. Send me an
e-mail if you want it.

John

Subject: Unshuffle algorithm

From: Sven

Date: 4 Aug, 2007 13:31:35

Message: 3 of 3

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <f91sg2$3gh$1@fred.mathworks.com>...
> "Sven " <sven.holcombe@removethis.gmail.com> wrote in message
> <f91dom$3hv$1@fred.mathworks.com>...
> > Hi there,
> > I have an array of numbers made up of two sequences that
> > have been sorted. I am trying to find an algorithm that can
> > extract separate arrays made up of these sequences.
> >
> > For example:
> > arr1 = sort([1:5 7:0.5:10]);
>
> If I might ask, what is the source of this problem?
> Its exactly the second time I've seen it come up,
> the last being roughly 1.5 years ago.
>
> This is, as I see it, a variant of clustering problem.
> I can supply a code that does it, using my
> consolidator tool as part of the engine. I'd not
> seen a reason to post it on the file exchange the
> first time it was asked.
>
> Its a bit long to paste in here though. Send me an
> e-mail if you want it.
>
> John
>

Hi John, thanks for the input.
Actually it was for a way to unshuffle a set of dicom images
that had been converted to flat images without metadata. The
filenames were ordered correctly spatially, but this meant
that two separate series had been intertwined because they
overlapped. I'm using past tense here because the original
dicom files have now been tracked down, and I'm sure that I
can now use the metadata to sort things out correctly.
So it's no longer an issue to work out an unshuffling
algorithm, but thanks very much for your interest.

Cheers,
Sven.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
algorithm Sven 4 Aug, 2007 04:40:20
sort Sven 4 Aug, 2007 04:40:20
indexing Sven 4 Aug, 2007 04:40:20
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com