MATLAB Answers


Regarding matlab cody solutions

Asked by nagasai thumati on 5 Sep 2019
Latest activity Commented on by Stephen Cobeldick on 6 Sep 2019
I have very basic knowledge in matlab programming. So, I decided to improve my matlab programming knowledge by doing some Matlab Cody exercises. As I'm a beginner in Matlab Programming, I couldn't able to solve more than 10 problems in Matlab Cody. I have tried to look at others soultions . Unfortunately , I cannot see others solutions. I cannot even see the solutions of others for the problems that I have already solved. Then what is the purpose of Cody when you cannot improve your coding by looking at various possibilities of solutons from others. It really didn't make any sense for me . Can somebody tell me the way to improve my coding knowledge in matlab?


on 5 Sep 2019
Thank you, Guillaume, for your response and the mention. In light of what has already been posted here, I would indicate that Cody is not the place to go for gaining rudimentary knowledge of MATLAB programming. As has been mentioned, there are great resources for this purpose, such as MATLAB Onramp.
However, once a user has basic knowledge of MATLAB programming, Cody is the perfect place to test one's skills and learn new tricks that can help improve day-to-day programming.
Now, lest anyone misinterpret "tricks," I am not referring to the eval, regexp, etc. hacks and cheats that are used to artificially minimize scores, but rather alternate function usage and creative combinations of built-in functions to perform tasks such as converting a number to an array of its digits and vice versa. There aren't built-in functions in MATLAB to do everything, but those that do exist can be combined in clever and efficient ways to create your own building blocks for more advanced code. And, Cody problems and (non-cheating) solutions can help users to write more efficient code. While cheats and hacks have plagued many problems, there are still many helpful solutions from various contributors, especially those in the top 20, or so. (Pro tip: if you're looking for helpful solutions, click on those that have different scores than yours and are not equal to the most common score.)
The Groups page of Cody contains over 60 curated problem groups (and counting) that cater to a variety of topics and skill levels. For beginners, I would recommend the Indexing series I, II, III, IV, V; Matrix Manipulation I, II, III; Matrix Patterns I, II, III; Sequences & Series I, II, III; Strings I, II, III (each roman numeral links to a different group). There is also a series of "Basics" groups that could be helpful (see the Groups page previously linked). Some of the other groups contain problems for intermediate and/or advanced coders.
I have found Cody to be a very useful tool to motivitate someone looking to improve their programming skills. And, the Cody team has put in consistent effort to improve the site over the years. Give it a shot.
Grant (@goc3 above) is being modest, but he's been the one to create most of the groups you see on Cody. As he says, "Indexing I" ( is a good place to start if you're just at the beginning of your MATLAB career. The "Cody Challenge" also has a lot of basic problems (
The idea behind Cody as a game is that we don't want to make it too easy for you to see other people's answers before you try to solve the problem. Otherwise it's too tempting to simply look at the answer before you make an effort. But after you've solved a few problems, you can go bck and look at answers from earlier problems and all the answers will be visible to you.
Speaking for myself, I would say that some of my best learning happens when I work hard on a problem, come up with an answer, and only THEN peek at other people's solutions. You learn amazing stuff that way.
And Guillaume and Grant have both pointed out that there are dumb cheats that you should just ignore. Learn from what's good. Don't learn from what's bad.
"...there are dumb cheats that you should just ignore. Learn from what's good. Don't learn from what's bad."
This is begging the question: exactly how is a beginner supposed to know the difference?

Sign in to comment.


2 Answers

Answer by Cris LaPierre
on 5 Sep 2019
Edited by Cris LaPierre
on 5 Sep 2019
 Accepted Answer

Cody is meant more as a game. It offers a chance to solve various challenges and then compare your solution to what others with "larger" solution sizes have done. That is the one caveat - you can't see solutions smaller than your code size.
If you want to learn more about coding, you should instead consider going through a self-paced training or online class. In MATLAB, click on the Learn MATLAB button.
This will take you to the MATLAB and Simulink Training page. If you are new to MATLAB, the best place to start is with MATLAB Onramp, a free, 2 hour introduction to programming in MATLAB. Other free onramps introduce you to Simulink and Deep Learning. Only the Onramps are free, but if you are a student, you may have access to additional courses. Use the My Courses page to explore.
On a new install, there is also a Getting Started banner that takes you to the Getting Started with MATLAB page. Here, you will find tutorials and additional info to help you learn.
If you would like more of a formal introduction, consider looking at MOOCs (Massive Open Online Courses). For example, Introduction to Programming with MATLAB on Coursera.

  1 Comment

Thank you so much

Sign in to comment.

Answer by Guillaume
on 5 Sep 2019

Once you solve a problem, you can see other solutions of the same size or larger. You won't be able to see smaller solutions until you solve another problem in the same category. If that is not what is happening, then give us the list of problems you have solved and I'll ask the cody people to look at it.
Indeed there is not currently any way to see the solution to a problem you haven't solved. But any solution, even if not very good will allow you to unlock all the solutions (once you solve another problem).

  1 Comment

Thank you Guillaume

Sign in to comment.