About Cody

Cody™ is a MATLAB Central game that challenges and expands your knowledge of MATLAB and Simulink®. As a web service provided to the community, Cody helps you sharpen your programming skills by solving problems and interacting with other members of the community. With Cody, you can:

To play, you need a Community Profile.

Play now!

Your use of Cody is subject to the MATLAB Central Terms of Use.

Solve Problems

When you see an interesting problem, select it. After the problem opens, click the Solve This Now! button and submit your solution. Don't worry about hurting your score or your pride by submitting an incorrect solution. Other players do not see your name with an incorrect solution, nor does an incorrect solution affect your score.

Suppose you choose to solve this problem:

Given an input number x, return the output value x+1.

The author of the problem always provides a starting point, the function template. For our example, the function template is

function y = plus_one(x)
    y = x;

The function template does not return the correct solution. In the example, the player edits the function template by adding + 1 to make the code work, as shown below.

function y = plus_one(x)
    y = x + 1;

When you as player submit this code, you receive the correct solution. Now try your hand at another problem.

Solution Size

Writing succinct code earns you a better result. Cody uses a node-count calculation to determine the solution size based on the number of nodes in the parse tree. Think of size as code length. Comments do not contribute to code size.

To illustrate how Cody determines size, here are two solutions to the plus-one problem.

  • Solution 1 has a size of 12.
  •   function y = plus_one(x)
          y = x+1;
  • Solution 2 has a size of 16.
  •   function y = plus_one(x)
          z = x;
          y = z+1;

Both functions return the correct solution, but the first solution provides the better score due to its smaller size.

For the Modeling and Simulation Challenge problems, solution size is a function of the number of elements in your model, including blocks, signals and signal branches.

Solution Evaluation and Measurement

Cody evaluates each solution against a number of tests. Cody determines whether your solution passes these tests and measures the size of your code. Measuring the solution based on code size provides a simple, objective, consistent, and smooth distribution of code sizes for any given problem, as opposed to large, uniform clusters.

The leading solution is the first solution submitted that has the smallest size. When a solution is too long to evaluate, Cody returns the message:

The server has encountered a problem.

To try out the official scoring code yourself, check out calculating size on File Exchange.

Improving Your Score

To improve your score, solve problems correctly and contribute problems. You earn:

  • 10 points for the first correct solution you submit for each problem
  • 15 points each time you submit a Community problem

Unlocking Cody Challenge Problems

Initially, you see only three Cody Challenge problems. Each time you solve one, Cody unlocks three more. The more you solve, the more Cody reveals to you.

Unlocking Solutions

Cody calculates a size for each solution. When you submit a correct solution to a problem, you can see other solutions of the same size (that is, the same length or longer), but not shorter solutions.

Each time you solve a new problem, you unlock all solutions to your previously solved problems in the same group.

Find Content

You can find content based on defined categories, such as Problems, Solutions, Players, and Comments. After you select a category, Cody also provides options to quickly find what you need.

Find Problems

From the Problems page, you can find problems by filtering your search using the Problems category, a problem group, and search directives you type in the search box. 

Filter Options for Finding Problems

Filter Options for Finding Problems


Cody provides several defined problem groups.

  • The Community group contains problems contributed by Cody players. This group is the default.
  • The Cody Challenge group contains problems created by Cody administrators. This group starts with three problems and unlocks more problems as you solve them.
  • Other groups, such as Tiles Challenge, ASEE Challenge, and Modeling and Simulation Challenge, are also created by Cody administrators. These groups contain problems related to a common theme, such as MATLAB Central contests or professional organizations.

Find Solutions

After you select a problem, Cody provides options to filter solutions using a solution map or a solution list. Cody also provides a Status filter in the left navigational pane to find correct or incorrect solutions from the Solutions page.

Solution Map

Solution Map for Problem 2.

The Solution Map plots solutions as points against two axes: order of arrival (horizontally) and code size (vertically). Correct solutions are green circles. Incorrect answers are red X. Rails of solid green indicate a single obvious answer. More than one rail indicates more than one straightforward answer. 

Using the Solution Map

  • To zoom in to activity on the Solution Map, click and drag the cursor, drawing a rectangle over the area.
  • To reset the view, double-click in the map area.
  • To select a solution, click on a green circle or red X.

Using Search Directives

You can find problems, solutions, or players by specifying search directives in the search box or by editing the URL.

From the Search Problems page, specify these directives in the search box.

Problem Search



Problem identified by this number



Problems with this group name


group:"Cody Challenge"

Problems with these specific tags


tag:"matlab 101"

Author with this name



Author identified by this number



Solver with this name



Solver identified by with this identification number



Problem that supports the use of this toolbox


product:"Control System Toolbox"

From the Search Solutions page, specify these directives in the search box.

Solution Result



Player with this name



Player with this ID number



Problem with this ID number



Solution with this size



Solution size with this range



From the Search Players page, specify these directives in the search box.

Player Result



Player with this ID number



Player with this name



Player with this email address



Players with a public profile in which the Company/Organization field contains this string



Using Directives

  • To search for a multi-word phrase, enclose the phrase in quotation marks; for example, player:"Ned Gulley".
  • To narrow search results, use combinations of directives in the same search. Be sure to include a space between each directive. The syntax player:"Ned Gulley" size_range:10-20 finds all solutions by players with the name Ned Gulley and a solution size between 10 and 20.
  • To exclude solutions from your search results, insert a minus sign (-) before the directive syntax. The syntax -player:"Ned" finds solutions from all players except those with the name Ned.

Contribute Problems

Any Cody player, with a score of 100 or more, can challenge others by adding problems to the Community group. If you have a problem without a solution in mind or are looking for a better way to solve it, post the problem in the Community group to learn what other players can offer.

Follow these guidelines for adding problems:

  1. From the main page, select the Create a Problem button.

    Problem Button

  2. Enter both a descriptive title and a meaningful description. Include sample input and output values.

    Problem Title and Descripiton Area
  3. Provide a function template to help players get started. Be sure to change the variable your_fcn_name to a meaningful descriptor of your specific problem. To continue with the example used earlier, your_fcn_name becomes plus_one.
    Function Template Area of the Form
  4. Write tests for a test suite to validate solutions from players. You can provide your own solution to validate your tests. Be sure to change the generic function name your_fcn_name referenced in the test suite to your specific function name.
    Test Suite Area of the Form

    Contribute a problem!


  • Cody does not handle graphical problems yet.
  • Cody supports MATLAB and not the toolboxes.

Earn Badges

As you contribute to Cody, you’ll earn badges and points that increase your standing in the Cody community.

What badges can I earn? How can I earn this badge? Points Awarded


Solve a problem for the first time.



Like a problem or solution.



Add a comment to a problem or solution.



Create a problem.



Solve a problem with a best solution.


Quiz Master

50 solvers must solve a problem you created.



Must receive 10 likes for a problem you created.



Must receive 10 likes for a solution you submitted.



Must receive 25 total likes for the problems you created.



Must receive 50 total likes for the solutions you submitted.



Create 10 problems.


Speed Demon

Solve a problem first.


Cody Challenge Master

Solve all the problems in the Cody Challenge problem group.


Tiles Challenge Master

Solve all the problems in the Tiles Challenge problem group.


ASEE Challenge Master

Solve all the problems in the ASEE Challenge problem group.


Modeling and Simulation Challenger Master

Solve all the problems in the Modeling and Simulation Challenge problem group.



Solve 500 problems.