Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 170816

Submitted on 30 Nov 2012 by Evan

Correct

21Size
Leading solution size is 18.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
n = 1;
Title_correct = 'Times 2 - START HERE';
assert(strcmp(Cody_Title(n),Title_correct))
ans =
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
      <meta http-equiv="X-UA-Compatible" content="IE=8"/>
      	<script type="text/javascript" src="/includes_content/nextgen/scripts/jquery/jquery-latest.js"></script>
      <!-- START OF GLOBAL NAV -->
  <link rel="stylesheet" href="/matlabcentral/css/sitewide.css" type="text/css">
  <link rel="stylesheet" href="/matlabcentral/css/mlc.css" type="text/css">
  <!--[if lt IE 7]>
  <link href="/matlabcentral/css/ie6down.css" type="text/css" rel="stylesheet">
  <![endif]-->
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="keywords" content="file exchange, matlab answers, newsgroup access, link exchange, matlab blog, matlab central, simulink blog, matlab community, matlab and simulink community">
    <link rel="stylesheet" type="text/css" media="print" href="/matlabcentral/css/print.css" />
    <title>Times 2 - START HERE - MATLAB Cody - MATLAB Central</title>
    <link rel="stylesheet" type="text/css" href="/matlabcentral/css/cody.css">
<link href="/matlabcentral/cody/stylesheets/960.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/application.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/editor.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/jquery.jqplot.min.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<script src="/matlabcentral/cody/javascripts/jquery_ujs.js?1351692448" type="text/javascript"></script>
<script src="/matlabcentral/cody/javascripts/jquery-ui.min.js?1351692448" type="text/javascript"></script>
<script src="/matlabcentral/cody/javascripts/application.js?1351692448" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="kvVFyCUxjorpuJ+UJwcFjWEcJM54lTNr/j/uOiVaPpU=" name="csrf-token" />
  </head>
    <body>
      <div id="header">
  <div class="wrapper">
  <!--put nothing in left div - only 11px wide shadow -->
    <div class="main">
        	<div id="logo"><a href="/matlabcentral/" title="MATLAB Central Home"><img src="/matlabcentral/images/mlclogo-whitebgd.gif" alt="MATLAB Central" /></a></div>
        <div id="headertools">
<script language="JavaScript1.3" type="text/javascript">
function submitForm(query){
	choice = document.forms['searchForm'].elements['search_submit'].value;
	if (choice == "entire1" || choice == "contest" || choice == "matlabcentral" || choice == "blogs"){
	   var newElem = document.createElement("input");
	   newElem.type = "hidden";
	   newElem.name = "q";
	   newElem.value = query.value;
	   document.forms['searchForm'].appendChild(newElem);
	   submit_action = '/searchresults/';
	}
	switch(choice){
	   case "matlabcentral":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "matlabcentral";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 0;
	      break
	   case "fileexchange":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/fileexchange/";
	      selected_index = 1;
	      break
	   case "answers":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/answers/";
	      selected_index = 2;
	      break
	   case "cssm":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "search_string";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
		  submit_action = "/matlabcentral/newsreader/search_results";
	      selected_index = 3;
	      break
	   case "linkexchange":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/linkexchange/";
	      selected_index = 4;
	      break
	   case "blogs":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "blogs";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 5;
	      break
	   case "trendy":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "search";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/trendy";
	      selected_index = 6;
	      break
	   case "cody":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/cody/";
	      selected_index = 7;
	      break
	   case "contest":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "contest";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 8;
	      break
	   case "entire1":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "entiresite";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 9;
	      break
	   default:
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "entiresite";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 9;
	      break
	}
	document.forms['searchForm'].elements['search_submit'].selectedIndex = selected_index;
	document.forms['searchForm'].elements['query'].value = query.value;
	document.forms['searchForm'].action = submit_action;
}
</SCRIPT>
  <form name="searchForm" method="GET" action="" style="margin:0px; margin-top:5px; font-size:90%" onSubmit="submitForm(query)">
          <label for="search">Search: </label>
        <select name="search_submit" style="font-size:9px ">
         	 <option value = "matlabcentral">MATLAB Central</option>
          	<option value = "fileexchange">&nbsp;&nbsp;&nbsp;File Exchange</option>
          	<option value = "answers">&nbsp;&nbsp;&nbsp;Answers</option>
            <option value = "cssm">&nbsp;&nbsp;&nbsp;Newsgroup</option>
          	<option value = "linkexchange">&nbsp;&nbsp;&nbsp;Link Exchange</option>
          	<option value = "blogs">&nbsp;&nbsp;&nbsp;Blogs</option>
          	<option value = "trendy">&nbsp;&nbsp;&nbsp;Trendy</option>
          	<option value = "cody" selected>&nbsp;&nbsp;&nbsp;Cody</option>
          	<option value = "contest">&nbsp;&nbsp;&nbsp;Contest</option>
          <option value = "entire1">MathWorks.com</option>
        </select>
<input type="text" name="query" size="10" class="formelem" value="">
<input type="submit" value="Go" class="formelem gobutton" >
</form>
		  <ol id="access2">
  <li class="first">
    <a href="http://www.mathworks.com/accesslogin/createProfile.do?uri=http%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fcody%2Fproblems%2F1" rel="nofollow">Create Account</a>
  </li>
  <li>
    <a href="https://www.mathworks.com/accesslogin/index_fe.do?uri=http%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fcody%2Fproblems%2F1" rel="nofollow">Log In</a>
  </li>
</ol>
      </div>
        <div id="globalnav">
        <!-- from includes/global_nav.html -->
        <ol>
                <li class=";" >
                        <a href="/matlabcentral/fileexchange/">File Exchange</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/answers/">Answers</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/newsreader/">Newsgroup</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/linkexchange/">Link Exchange</a>
                </li>
                <li class=";" >
                        <a href="http://blogs.mathworks.com/">Blogs</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/trendy">Trendy</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/cody">Cody</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/contest/">Contest</a>
                </li>
                <li class="icon mathworks" >
                        <a href="/">MathWorks.com</a>
                </li>
        </ol>
      </div>
    </div>
  </div>
</div>
      	<div class="container_240">
    	<div class="cody_content_container">
        	<div class="grid_35 push_2">
	<div id="localnav_container" class="localnav_container">
    	<div class="localnav">
      	<ul>
          <li class=""><a href="/matlabcentral/cody/problems" id="cody_problems_list_id">Problems</a></li>
  				<li class=""><a href="/matlabcentral/cody/solutions" id="cody_all_solutions_list_id">Solutions</a></li>
          <li class=""><a href="/matlabcentral/cody/players" id="cody_players_list_id"...
2
Pass
 
%%
n = 2;
Title_correct = 'Make the vector [1 2 3 4 5 6 7 8 9 10]';
assert(strcmp(Cody_Title(n),Title_correct))
ans =
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
      <meta http-equiv="X-UA-Compatible" content="IE=8"/>
      	<script type="text/javascript" src="/includes_content/nextgen/scripts/jquery/jquery-latest.js"></script>
      <!-- START OF GLOBAL NAV -->
  <link rel="stylesheet" href="/matlabcentral/css/sitewide.css" type="text/css">
  <link rel="stylesheet" href="/matlabcentral/css/mlc.css" type="text/css">
  <!--[if lt IE 7]>
  <link href="/matlabcentral/css/ie6down.css" type="text/css" rel="stylesheet">
  <![endif]-->
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="keywords" content="file exchange, matlab answers, newsgroup access, link exchange, matlab blog, matlab central, simulink blog, matlab community, matlab and simulink community">
    <link rel="stylesheet" type="text/css" media="print" href="/matlabcentral/css/print.css" />
    <title>Make the vector [1 2 3 4 5 6 7 8 9 10] - MATLAB Cody - MATLAB Central</title>
    <link rel="stylesheet" type="text/css" href="/matlabcentral/css/cody.css">
<link href="/matlabcentral/cody/stylesheets/960.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/application.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/editor.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/jquery.jqplot.min.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<script src="/matlabcentral/cody/javascripts/jquery_ujs.js?1351692448" type="text/javascript"></script>
<script src="/matlabcentral/cody/javascripts/jquery-ui.min.js?1351692448" type="text/javascript"></script>
<script src="/matlabcentral/cody/javascripts/application.js?1351692448" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="TDG2Fk3zUEhf6Pdq/Xw4K2156Ed3na+47QjEvjVSXrU=" name="csrf-token" />
  </head>
    <body>
      <div id="header">
  <div class="wrapper">
  <!--put nothing in left div - only 11px wide shadow -->
    <div class="main">
        	<div id="logo"><a href="/matlabcentral/" title="MATLAB Central Home"><img src="/matlabcentral/images/mlclogo-whitebgd.gif" alt="MATLAB Central" /></a></div>
        <div id="headertools">
<script language="JavaScript1.3" type="text/javascript">
function submitForm(query){
	choice = document.forms['searchForm'].elements['search_submit'].value;
	if (choice == "entire1" || choice == "contest" || choice == "matlabcentral" || choice == "blogs"){
	   var newElem = document.createElement("input");
	   newElem.type = "hidden";
	   newElem.name = "q";
	   newElem.value = query.value;
	   document.forms['searchForm'].appendChild(newElem);
	   submit_action = '/searchresults/';
	}
	switch(choice){
	   case "matlabcentral":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "matlabcentral";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 0;
	      break
	   case "fileexchange":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/fileexchange/";
	      selected_index = 1;
	      break
	   case "answers":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/answers/";
	      selected_index = 2;
	      break
	   case "cssm":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "search_string";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
		  submit_action = "/matlabcentral/newsreader/search_results";
	      selected_index = 3;
	      break
	   case "linkexchange":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/linkexchange/";
	      selected_index = 4;
	      break
	   case "blogs":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "blogs";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 5;
	      break
	   case "trendy":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "search";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/trendy";
	      selected_index = 6;
	      break
	   case "cody":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/cody/";
	      selected_index = 7;
	      break
	   case "contest":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "contest";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 8;
	      break
	   case "entire1":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "entiresite";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 9;
	      break
	   default:
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "entiresite";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 9;
	      break
	}
	document.forms['searchForm'].elements['search_submit'].selectedIndex = selected_index;
	document.forms['searchForm'].elements['query'].value = query.value;
	document.forms['searchForm'].action = submit_action;
}
</SCRIPT>
  <form name="searchForm" method="GET" action="" style="margin:0px; margin-top:5px; font-size:90%" onSubmit="submitForm(query)">
          <label for="search">Search: </label>
        <select name="search_submit" style="font-size:9px ">
         	 <option value = "matlabcentral">MATLAB Central</option>
          	<option value = "fileexchange">&nbsp;&nbsp;&nbsp;File Exchange</option>
          	<option value = "answers">&nbsp;&nbsp;&nbsp;Answers</option>
            <option value = "cssm">&nbsp;&nbsp;&nbsp;Newsgroup</option>
          	<option value = "linkexchange">&nbsp;&nbsp;&nbsp;Link Exchange</option>
          	<option value = "blogs">&nbsp;&nbsp;&nbsp;Blogs</option>
          	<option value = "trendy">&nbsp;&nbsp;&nbsp;Trendy</option>
          	<option value = "cody" selected>&nbsp;&nbsp;&nbsp;Cody</option>
          	<option value = "contest">&nbsp;&nbsp;&nbsp;Contest</option>
          <option value = "entire1">MathWorks.com</option>
        </select>
<input type="text" name="query" size="10" class="formelem" value="">
<input type="submit" value="Go" class="formelem gobutton" >
</form>
		  <ol id="access2">
  <li class="first">
    <a href="http://www.mathworks.com/accesslogin/createProfile.do?uri=http%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fcody%2Fproblems%2F2" rel="nofollow">Create Account</a>
  </li>
  <li>
    <a href="https://www.mathworks.com/accesslogin/index_fe.do?uri=http%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fcody%2Fproblems%2F2" rel="nofollow">Log In</a>
  </li>
</ol>
      </div>
        <div id="globalnav">
        <!-- from includes/global_nav.html -->
        <ol>
                <li class=";" >
                        <a href="/matlabcentral/fileexchange/">File Exchange</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/answers/">Answers</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/newsreader/">Newsgroup</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/linkexchange/">Link Exchange</a>
                </li>
                <li class=";" >
                        <a href="http://blogs.mathworks.com/">Blogs</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/trendy">Trendy</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/cody">Cody</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/contest/">Contest</a>
                </li>
                <li class="icon mathworks" >
                        <a href="/">MathWorks.com</a>
                </li>
        </ol>
      </div>
    </div>
  </div>
</div>
      	<div class="container_240">
    	<div class="cody_content_container">
        	<div class="grid_35 push_2">
	<div id="localnav_container" class="localnav_container">
    	<div class="localnav">
      	<ul>
          <li class=""><a href="/matlabcentral/cody/problems" id="cody_problems_list_id">Problems</a></li>
  				<li class=""><a href="/matlabcentral/cody/solutions" id="cody_all_solutions_list_id">Solutions</a></li>
          <li class=""><a href="/matlabcentral/cody/players" id="cod...
3
Pass
 
%%
n = 110;
Title_correct = 'Make an N-dimensional Multiplication Table';
% This problem hurts my head
assert(strcmp(Cody_Title(n),Title_correct))
ans =
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
      <meta http-equiv="X-UA-Compatible" content="IE=8"/>
      	<script type="text/javascript" src="/includes_content/nextgen/scripts/jquery/jquery-latest.js"></script>
      <!-- START OF GLOBAL NAV -->
  <link rel="stylesheet" href="/matlabcentral/css/sitewide.css" type="text/css">
  <link rel="stylesheet" href="/matlabcentral/css/mlc.css" type="text/css">
  <!--[if lt IE 7]>
  <link href="/matlabcentral/css/ie6down.css" type="text/css" rel="stylesheet">
  <![endif]-->
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="keywords" content="file exchange, matlab answers, newsgroup access, link exchange, matlab blog, matlab central, simulink blog, matlab community, matlab and simulink community">
    <link rel="stylesheet" type="text/css" media="print" href="/matlabcentral/css/print.css" />
    <title>Make an N-dimensional Multiplication Table - MATLAB Cody - MATLAB Central</title>
    <link rel="stylesheet" type="text/css" href="/matlabcentral/css/cody.css">
<link href="/matlabcentral/cody/stylesheets/960.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/application.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/editor.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/jquery.jqplot.min.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<script src="/matlabcentral/cody/javascripts/jquery_ujs.js?1351692448" type="text/javascript"></script>
<script src="/matlabcentral/cody/javascripts/jquery-ui.min.js?1351692448" type="text/javascript"></script>
<script src="/matlabcentral/cody/javascripts/application.js?1351692448" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="eWn5ewkJ/3FtmyvS90PfTokBRQ1kMTyV9Av8gFsbxXU=" name="csrf-token" />
  </head>
    <body>
      <div id="header">
  <div class="wrapper">
  <!--put nothing in left div - only 11px wide shadow -->
    <div class="main">
        	<div id="logo"><a href="/matlabcentral/" title="MATLAB Central Home"><img src="/matlabcentral/images/mlclogo-whitebgd.gif" alt="MATLAB Central" /></a></div>
        <div id="headertools">
<script language="JavaScript1.3" type="text/javascript">
function submitForm(query){
	choice = document.forms['searchForm'].elements['search_submit'].value;
	if (choice == "entire1" || choice == "contest" || choice == "matlabcentral" || choice == "blogs"){
	   var newElem = document.createElement("input");
	   newElem.type = "hidden";
	   newElem.name = "q";
	   newElem.value = query.value;
	   document.forms['searchForm'].appendChild(newElem);
	   submit_action = '/searchresults/';
	}
	switch(choice){
	   case "matlabcentral":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "matlabcentral";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 0;
	      break
	   case "fileexchange":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/fileexchange/";
	      selected_index = 1;
	      break
	   case "answers":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/answers/";
	      selected_index = 2;
	      break
	   case "cssm":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "search_string";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
		  submit_action = "/matlabcentral/newsreader/search_results";
	      selected_index = 3;
	      break
	   case "linkexchange":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/linkexchange/";
	      selected_index = 4;
	      break
	   case "blogs":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "blogs";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 5;
	      break
	   case "trendy":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "search";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/trendy";
	      selected_index = 6;
	      break
	   case "cody":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/cody/";
	      selected_index = 7;
	      break
	   case "contest":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "contest";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 8;
	      break
	   case "entire1":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "entiresite";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 9;
	      break
	   default:
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "entiresite";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 9;
	      break
	}
	document.forms['searchForm'].elements['search_submit'].selectedIndex = selected_index;
	document.forms['searchForm'].elements['query'].value = query.value;
	document.forms['searchForm'].action = submit_action;
}
</SCRIPT>
  <form name="searchForm" method="GET" action="" style="margin:0px; margin-top:5px; font-size:90%" onSubmit="submitForm(query)">
          <label for="search">Search: </label>
        <select name="search_submit" style="font-size:9px ">
         	 <option value = "matlabcentral">MATLAB Central</option>
          	<option value = "fileexchange">&nbsp;&nbsp;&nbsp;File Exchange</option>
          	<option value = "answers">&nbsp;&nbsp;&nbsp;Answers</option>
            <option value = "cssm">&nbsp;&nbsp;&nbsp;Newsgroup</option>
          	<option value = "linkexchange">&nbsp;&nbsp;&nbsp;Link Exchange</option>
          	<option value = "blogs">&nbsp;&nbsp;&nbsp;Blogs</option>
          	<option value = "trendy">&nbsp;&nbsp;&nbsp;Trendy</option>
          	<option value = "cody" selected>&nbsp;&nbsp;&nbsp;Cody</option>
          	<option value = "contest">&nbsp;&nbsp;&nbsp;Contest</option>
          <option value = "entire1">MathWorks.com</option>
        </select>
<input type="text" name="query" size="10" class="formelem" value="">
<input type="submit" value="Go" class="formelem gobutton" >
</form>
		  <ol id="access2">
  <li class="first">
    <a href="http://www.mathworks.com/accesslogin/createProfile.do?uri=http%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fcody%2Fproblems%2F110" rel="nofollow">Create Account</a>
  </li>
  <li>
    <a href="https://www.mathworks.com/accesslogin/index_fe.do?uri=http%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fcody%2Fproblems%2F110" rel="nofollow">Log In</a>
  </li>
</ol>
      </div>
        <div id="globalnav">
        <!-- from includes/global_nav.html -->
        <ol>
                <li class=";" >
                        <a href="/matlabcentral/fileexchange/">File Exchange</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/answers/">Answers</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/newsreader/">Newsgroup</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/linkexchange/">Link Exchange</a>
                </li>
                <li class=";" >
                        <a href="http://blogs.mathworks.com/">Blogs</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/trendy">Trendy</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/cody">Cody</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/contest/">Contest</a>
                </li>
                <li class="icon mathworks" >
                        <a href="/">MathWorks.com</a>
                </li>
        </ol>
      </div>
    </div>
  </div>
</div>
      	<div class="container_240">
    	<div class="cody_content_container">
        	<div class="grid_35 push_2">
	<div id="localnav_container" class="localnav_container">
    	<div class="localnav">
      	<ul>
          <li class=""><a href="/matlabcentral/cody/problems" id="cody_problems_list_id">Problems</a></li>
  				<li class=""><a href="/matlabcentral/cody/solutions" id="cody_all_solutions_list_id">Solutions</a></li>
          <li class=""><a href="/matlabcentral/cody/players"...
4
Pass
 
%%
n = 808;
Title_correct = 'Hamming Weight - Fast';
assert(strcmp(Cody_Title(n),Title_correct))
ans =
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
      <meta http-equiv="X-UA-Compatible" content="IE=8"/>
      	<script type="text/javascript" src="/includes_content/nextgen/scripts/jquery/jquery-latest.js"></script>
      <!-- START OF GLOBAL NAV -->
  <link rel="stylesheet" href="/matlabcentral/css/sitewide.css" type="text/css">
  <link rel="stylesheet" href="/matlabcentral/css/mlc.css" type="text/css">
  <!--[if lt IE 7]>
  <link href="/matlabcentral/css/ie6down.css" type="text/css" rel="stylesheet">
  <![endif]-->
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="keywords" content="file exchange, matlab answers, newsgroup access, link exchange, matlab blog, matlab central, simulink blog, matlab community, matlab and simulink community">
    <link rel="stylesheet" type="text/css" media="print" href="/matlabcentral/css/print.css" />
    <title>Hamming Weight - Fast - MATLAB Cody - MATLAB Central</title>
    <link rel="stylesheet" type="text/css" href="/matlabcentral/css/cody.css">
<link href="/matlabcentral/cody/stylesheets/960.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/application.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/editor.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<link href="/matlabcentral/cody/stylesheets/jquery.jqplot.min.css?1351692448" media="screen" rel="stylesheet" type="text/css" />
<script src="/matlabcentral/cody/javascripts/jquery_ujs.js?1351692448" type="text/javascript"></script>
<script src="/matlabcentral/cody/javascripts/jquery-ui.min.js?1351692448" type="text/javascript"></script>
<script src="/matlabcentral/cody/javascripts/application.js?1351692448" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="Frbpjk2Iu83vMOaioMrQOgjvR+KoNn0HQufNAIUu1DM=" name="csrf-token" />
  </head>
    <body>
      <div id="header">
  <div class="wrapper">
  <!--put nothing in left div - only 11px wide shadow -->
    <div class="main">
        	<div id="logo"><a href="/matlabcentral/" title="MATLAB Central Home"><img src="/matlabcentral/images/mlclogo-whitebgd.gif" alt="MATLAB Central" /></a></div>
        <div id="headertools">
<script language="JavaScript1.3" type="text/javascript">
function submitForm(query){
	choice = document.forms['searchForm'].elements['search_submit'].value;
	if (choice == "entire1" || choice == "contest" || choice == "matlabcentral" || choice == "blogs"){
	   var newElem = document.createElement("input");
	   newElem.type = "hidden";
	   newElem.name = "q";
	   newElem.value = query.value;
	   document.forms['searchForm'].appendChild(newElem);
	   submit_action = '/searchresults/';
	}
	switch(choice){
	   case "matlabcentral":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "matlabcentral";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 0;
	      break
	   case "fileexchange":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/fileexchange/";
	      selected_index = 1;
	      break
	   case "answers":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/answers/";
	      selected_index = 2;
	      break
	   case "cssm":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "search_string";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
		  submit_action = "/matlabcentral/newsreader/search_results";
	      selected_index = 3;
	      break
	   case "linkexchange":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/linkexchange/";
	      selected_index = 4;
	      break
	   case "blogs":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "blogs";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 5;
	      break
	   case "trendy":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "search";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/trendy";
	      selected_index = 6;
	      break
	   case "cody":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "term";
	      newElem.value = query.value;
	      newElem.classname = "formelem";
	      document.forms['searchForm'].appendChild(newElem);
	      submit_action = "/matlabcentral/cody/";
	      selected_index = 7;
	      break
	   case "contest":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "contest";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 8;
	      break
	   case "entire1":
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "entiresite";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 9;
	      break
	   default:
	      var newElem = document.createElement("input");
	      newElem.type = "hidden";
	      newElem.name = "c[]";
	      newElem.value = "entiresite";
	      document.forms['searchForm'].appendChild(newElem);
	      selected_index = 9;
	      break
	}
	document.forms['searchForm'].elements['search_submit'].selectedIndex = selected_index;
	document.forms['searchForm'].elements['query'].value = query.value;
	document.forms['searchForm'].action = submit_action;
}
</SCRIPT>
  <form name="searchForm" method="GET" action="" style="margin:0px; margin-top:5px; font-size:90%" onSubmit="submitForm(query)">
          <label for="search">Search: </label>
        <select name="search_submit" style="font-size:9px ">
         	 <option value = "matlabcentral">MATLAB Central</option>
          	<option value = "fileexchange">&nbsp;&nbsp;&nbsp;File Exchange</option>
          	<option value = "answers">&nbsp;&nbsp;&nbsp;Answers</option>
            <option value = "cssm">&nbsp;&nbsp;&nbsp;Newsgroup</option>
          	<option value = "linkexchange">&nbsp;&nbsp;&nbsp;Link Exchange</option>
          	<option value = "blogs">&nbsp;&nbsp;&nbsp;Blogs</option>
          	<option value = "trendy">&nbsp;&nbsp;&nbsp;Trendy</option>
          	<option value = "cody" selected>&nbsp;&nbsp;&nbsp;Cody</option>
          	<option value = "contest">&nbsp;&nbsp;&nbsp;Contest</option>
          <option value = "entire1">MathWorks.com</option>
        </select>
<input type="text" name="query" size="10" class="formelem" value="">
<input type="submit" value="Go" class="formelem gobutton" >
</form>
		  <ol id="access2">
  <li class="first">
    <a href="http://www.mathworks.com/accesslogin/createProfile.do?uri=http%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fcody%2Fproblems%2F808" rel="nofollow">Create Account</a>
  </li>
  <li>
    <a href="https://www.mathworks.com/accesslogin/index_fe.do?uri=http%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fcody%2Fproblems%2F808" rel="nofollow">Log In</a>
  </li>
</ol>
      </div>
        <div id="globalnav">
        <!-- from includes/global_nav.html -->
        <ol>
                <li class=";" >
                        <a href="/matlabcentral/fileexchange/">File Exchange</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/answers/">Answers</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/newsreader/">Newsgroup</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/linkexchange/">Link Exchange</a>
                </li>
                <li class=";" >
                        <a href="http://blogs.mathworks.com/">Blogs</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/trendy">Trendy</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/cody">Cody</a>
                </li>
                <li class=";" >
                        <a href="/matlabcentral/contest/">Contest</a>
                </li>
                <li class="icon mathworks" >
                        <a href="/">MathWorks.com</a>
                </li>
        </ol>
      </div>
    </div>
  </div>
</div>
      	<div class="container_240">
    	<div class="cody_content_container">
        	<div class="grid_35 push_2">
	<div id="localnav_container" class="localnav_container">
    	<div class="localnav">
      	<ul>
          <li class=""><a href="/matlabcentral/cody/problems" id="cody_problems_list_id">Problems</a></li>
  				<li class=""><a href="/matlabcentral/cody/solutions" id="cody_all_solutions_list_id">Solutions</a></li>
          <li class=""><a href="/matlabcentral/cody/players" id="cody_players_lis...