|
Rafael wrote:
> I am trying to write a function that will that take a random
> assortment of numbers (motif) and if the 'motif' is in the designated
> location of the longer chain of random numbers (protein), it will return
> as "1" or "true." Otherwise, it will return as "0". I'm not entirely
> familiar with how for works but here is my coding so far. I think it's
> on the right track; does anybody know what I did wrong.
>
> Thanks so much!
>
>
> function a=Motif_Match(motif,protein,location)
> [rows cols]=size(protein);
> if rows~=1
> disp('motif_match only accepts vectors')
minor detail...
Do you really only want row vector or wouldn't a column vector be just
as useful?
I'd suggest also when end w/ the error condition use error() instead of
disp() to abort since there's no point in going on anyway (and as you've
written it, it in effect does the same thing except you could
encapsulate the error stuff up front and eliminate the rest of the code
inside the conditional).
if rows~=1
error('motif_match only accepts vectors')
end
...
> for i=location:cols
> if motif==protein(i)
> a=1;
> end
> end
Your problem is fully specified -- what's the location of the required
match in the protein vector and what's the length of motif?
What is the range of the numeric values? It might be easier to convert
to a character representation and do a findstr() operation.
Need more poop...
--
|