Thread Subject: Explicit Loops

Subject: Explicit Loops

From: Justin

Date: 10 Nov, 2009 02:30:19

Message: 1 of 5

I am trying to write a function given a string of random letters and an integer N, the function will return an alphabetically sorted table of all smaller strings of that particular length N. I'm trying to do this without Matlab's sorting function or implicit looping features.

Example of what this should look like:
Example
protein = 'VSGKVRFP';
SortMotifs(protein, 4)
ans =
GKVR
KVRF
SGKV
VRFP
VSGK

I need an "explanation' on how to approach this problem. No direct answer is necessary. Thanks in advance.

Subject: Explicit Loops

From: John D'Errico

Date: 10 Nov, 2009 02:47:01

Message: 2 of 5

"Justin " <riley127099@yahoo.com> wrote in message <hdaj7r$81t$1@fred.mathworks.com>...
> I am trying to write a function given a string of random letters and an integer N, the function will return an alphabetically sorted table of all smaller strings of that particular length N. I'm trying to do this without Matlab's sorting function or implicit looping features.
>
> Example of what this should look like:
> Example
> protein = 'VSGKVRFP';
> SortMotifs(protein, 4)
> ans =
> GKVR
> KVRF
> SGKV
> VRFP
> VSGK
>
> I need an "explanation' on how to approach this problem. No direct answer is necessary. Thanks in advance.


help nchoosek

That should be the only explanation you need.

John

Subject: Explicit Loops

From: Matt Fig

Date: 10 Nov, 2009 02:59:02

Message: 3 of 5

What about iteratively indexing into protein, with index ii:

protein(ii:ii+N-1)

I will leave the limits of ii and the storage problem to you.

Subject: Explicit Loops

From: Justin

Date: 10 Nov, 2009 04:15:04

Message: 4 of 5

"Matt Fig" <spamanon@yahoo.com> wrote in message <hdaktm$je6$1@fred.mathworks.com>...
> What about iteratively indexing into protein, with index ii:
>
> protein(ii:ii+N-1)
>
> I will leave the limits of ii and the storage problem to you.

Okay thanks, but where do the explicit loops fit into all of this? How should I organize the function?

Subject: Explicit Loops

From: Justin

Date: 10 Nov, 2009 04:17:02

Message: 5 of 5

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <hdak75$79q$1@fred.mathworks.com>...
> "Justin " <riley127099@yahoo.com> wrote in message <hdaj7r$81t$1@fred.mathworks.com>...
> > I am trying to write a function given a string of random letters and an integer N, the function will return an alphabetically sorted table of all smaller strings of that particular length N. I'm trying to do this without Matlab's sorting function or implicit looping features.
> >
> > Example of what this should look like:
> > Example
> > protein = 'VSGKVRFP';
> > SortMotifs(protein, 4)
> > ans =
> > GKVR
> > KVRF
> > SGKV
> > VRFP
> > VSGK
> >
> > I need an "explanation' on how to approach this problem. No direct answer is necessary. Thanks in advance.
>
>
> help nchoosek
>
> That should be the only explanation you need.
>
> John

Thanks John. Unfortunately, that is not a viable option because it is a built-in matlab function, and I am trying to learn a way around this.

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
explicit looping Justin 9 Nov, 2009 21:34:03
loops Justin 9 Nov, 2009 21:34:03
while Justin 9 Nov, 2009 21:34:03
for Justin 9 Nov, 2009 21:34:03
bioinformatics Justin 9 Nov, 2009 21:34:03
sorting Justin 9 Nov, 2009 21:34:03
table Justin 9 Nov, 2009 21:34:03
rssFeed for this Thread

Contact us at files@mathworks.com