<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265226</link>
    <title>MATLAB Central Newsreader - Explicit Looping</title>
    <description>Feed for thread: Explicit Looping</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 07 Nov 2009 09:13:02 -0500</pubDate>
      <title>Explicit Looping</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265226#692863</link>
      <author>Rafael </author>
      <description>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 &quot;1&quot; or &quot;true.&quot; Otherwise, it will return as &quot;0&quot;. 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. &lt;br&gt;
&lt;br&gt;
Thanks so much!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
function a=Motif_Match(motif,protein,location)&lt;br&gt;
[rows cols]=size(protein);&lt;br&gt;
if rows~=1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;disp('motif_match only accepts vectors')&lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for i=location:cols&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if motif==protein(i)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a=1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end</description>
    </item>
    <item>
      <pubDate>Sat, 07 Nov 2009 14:14:01 -0500</pubDate>
      <title>Re: Explicit Looping</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265226#692887</link>
      <author>dpb</author>
      <description>Rafael wrote:&lt;br&gt;
&amp;gt; I am trying to write a function that will that take a random&lt;br&gt;
&amp;gt; assortment of numbers (motif) and if the 'motif' is in the designated&lt;br&gt;
&amp;gt; location of the longer chain of random numbers (protein), it will return&lt;br&gt;
&amp;gt; as &quot;1&quot; or &quot;true.&quot; Otherwise, it will return as &quot;0&quot;. I'm not entirely&lt;br&gt;
&amp;gt; familiar with how for works but here is my coding so far. I think it's&lt;br&gt;
&amp;gt; on the right track; does anybody know what I did wrong.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks so much!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function a=Motif_Match(motif,protein,location)&lt;br&gt;
&amp;gt; [rows cols]=size(protein);&lt;br&gt;
&amp;gt; if rows~=1&lt;br&gt;
&amp;gt;     disp('motif_match only accepts vectors')&lt;br&gt;
&lt;br&gt;
minor detail...&lt;br&gt;
&lt;br&gt;
Do you really only want row vector or wouldn't a column vector be just &lt;br&gt;
as useful?&lt;br&gt;
&lt;br&gt;
I'd suggest also when end w/ the error condition use error() instead of &lt;br&gt;
disp() to abort since there's no point in going on anyway (and as you've &lt;br&gt;
written it, it in effect does the same thing except you could &lt;br&gt;
encapsulate the error stuff up front and eliminate the rest of the code &lt;br&gt;
inside the conditional).&lt;br&gt;
&lt;br&gt;
if rows~=1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;error('motif_match only accepts vectors')&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
...&lt;br&gt;
&amp;gt; for i=location:cols&lt;br&gt;
&amp;gt;   if motif==protein(i)&lt;br&gt;
&amp;gt;     a=1;&lt;br&gt;
&amp;gt;   end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&lt;br&gt;
Your problem is fully specified -- what's the location of the required &lt;br&gt;
match in the protein vector and what's the length of motif?&lt;br&gt;
&lt;br&gt;
What is the range of the numeric values?  It might be easier to convert &lt;br&gt;
to a character representation and do a findstr() operation.&lt;br&gt;
&lt;br&gt;
Need more poop...&lt;br&gt;
&lt;br&gt;
--</description>
    </item>
    <item>
      <pubDate>Sat, 07 Nov 2009 14:26:50 -0500</pubDate>
      <title>Re: Explicit Looping</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265226#692892</link>
      <author>dpb</author>
      <description>dpb wrote:&lt;br&gt;
...&lt;br&gt;
&amp;gt; Your problem is fully specified ...&lt;br&gt;
&lt;br&gt;
dang!  That was _NOT_ fully specified, of course, intended...&lt;br&gt;
&lt;br&gt;
--</description>
    </item>
  </channel>
</rss>

