View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Code Metrics

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.1 | 98 ratings Rate this file 12 Downloads (last 30 days) File Size: 67.3 KB File ID: #10514 Version:

Code Metrics


Santosh Kasula (view profile)


23 Mar 2006 (Updated )

Generate code metrics for the specified directory

| Watch this File

File Information

CODEMETRICS computes the same code metrics that the File Exchange displays for all submissions. It allows you to see your metrics before submitting.

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (133)
03 Jul 2015 Neil Judell

Is there any way to get source that generated the MDF executable? Will not run on Windows x64 8.1, even with current copy of cygwin1.dll...

25 Mar 2014 Quy Phan

I happy

Comment only
20 Mar 2014 per isakson

CODEMETRICS reports one clash for each file in my test. Is that behavior intended? Anyhow, I replaced

% Locate.
clashname = which( fname );


% Locate.
if isscalar( which( fname, '-all' ) )
clashname = '';
clashname = which( fname );

in the subfunction, getClash. Now it reports no clashes in the same test.

Comment only
22 Mar 2013 Thomas Vanaret

Note : "Filename Clashes" metric is incorrect because it is based on Matlab "which" function WITHOUT "-all" option (private\generateStats > getClash - line 381).

Thus, it does not detect if the function name match many one in the Matlab Path.

Comment only
06 Nov 2008 Dan K

Dan K (view profile)

I have used this utility for quite a long time and really found it to be wonderfully useful. Unfortunately, it no longer works with the updated FEX format. I would be very grateful if it could be updated to work with the new FEX. One other functionality piece which would be very nice would be to have a summary of downloads page, which allowed one to easily see which of the fxdownloads are on the path, which are not, and to toggle the state of any given one. Thanks,

02 Sep 2008 bilal saeed

nice man

07 Aug 2008 FU Kechang  
01 Aug 2008 manzoor ahmad

i want to work on fhss

Comment only
19 Jul 2008 Oleg Verbitsky  
24 Jun 2008 ahmed salim  
16 May 2008 Tobias Kaulic

Hello I'm Tobias
I download your zip File. But when I klick on the exe File, come the Display, that one dll File not found. What kan I do??
I'm a German :)

Comment only
02 May 2008 ender karazeybek

it is necessary to my project.

Comment only
29 Apr 2008 gill gill


23 Apr 2008 tisa selma

it's great!

14 Apr 2008 kisalay choudhary  
08 Apr 2008 moumen ala  
07 Apr 2008 sure geo

it is realy useful to the beginners

17 Mar 2008 hussain ghf


16 Mar 2008 novia larasati  
09 Mar 2008 baqer soltani


Comment only
08 Mar 2008 liu yue  
06 Mar 2008 y jiang  
01 Mar 2008 Minh Nguyen  
27 Feb 2008 chetana prakash

Really it is good and helpm a lot

19 Feb 2008 kin dhameliya

very good

11 Feb 2008 hasan sadikin

very good

06 Feb 2008 venkat kanal

very good

30 Jan 2008 Theodosius Zaxaruck  
27 Jan 2008 zine leila

please can you tell wich version of matlab i must have in order to use turbo code in simulink

Comment only
23 Jan 2008 Sakkayaphop Pravesjit

Thanks, this is really useful for keeping track.

16 Jan 2008 chabane fouad


14 Jan 2008 G Brown

Thanks, this is really useful for keeping track.

03 Jan 2008 lekshmi nair


29 Dec 2007 M B  
14 Dec 2007 quyet pham


Comment only
14 Dec 2007 Frank Koch  
11 Dec 2007 Qureshi Irfan

Fine Effort

10 Dec 2007 zevallos luna


08 Dec 2007 Mansoor Ahmed  
01 Dec 2007 john rob  
29 Nov 2007 Gurmohan Singh  
27 Nov 2007 gh deng


26 Nov 2007 farzaneh asad  
13 Nov 2007 Joung minho

thak you

Comment only
02 Nov 2007 Yuntao Ju


Comment only
28 Oct 2007 Sang David

Thank you very much, but I desire to know its corresponding references.

Comment only
27 Oct 2007 akram daneshmand


22 Oct 2007 L N  
20 Oct 2007 he zhi


Comment only
22 Sep 2007 vinay bhardwaj  
19 Sep 2007 ricky127 deh

skjwhjskakahdkadhajkdhajkdhakdj ajkdehajkdhajkashadshakdhakdhkadh akjdhkajd kd akdkadkajd jkdjkd ajkd kdhkd hs

Comment only
16 Aug 2007 irfan fiaz

its fine

13 Aug 2007 henry wang

very good

29 Jul 2007 somaieh jokar  
17 Jul 2007 yong teen yih  
16 Jul 2007 liao susu

It is very good!

Comment only
13 Jul 2007 navid samimi

if may, you send this file for me.
i need for one research

Comment only
13 Jul 2007 abdul mukti

this good file, and very important to reads

03 Jul 2007 mohamed khatan  
03 Jul 2007 Mohammad Hassan Dinpajooh

Not bad

Comment only
26 Jun 2007 mobile mobilee


Comment only
07 Jun 2007 mike s

I got an error, then I fixed the proxy server and it is working great. I still have to be smart enough to put in the right search string...

05 Jun 2007 xia tian  
04 Jun 2007 Tuan Anh

Verry help full

21 May 2007 Gnanasekaran Thangavel

still I have to do more on this

21 May 2007 ert ert  
19 May 2007 fadela sabry

this project is very excellent


09 May 2007 tilak kumar  
12 Apr 2007 jesada sartthong  
05 Apr 2007 yu xue  
01 Apr 2007 saied emgary

Excellent Excellent

26 Mar 2007 Mike Oldfiled  
21 Mar 2007 souhir mansouri

no comment

16 Mar 2007 Ged Ridgway

The "help warnings" section of the code metrics penalizes me for having no "example" section in a Contents.m file and in a demo.m file that exists solely for the purposes of producing a published m-file (which is *all* example!)

I wonder if Contents.m should be checked separately (as in the "contents report" on a directory). And I wonder if it would be possible to skip/relax checks on blah.m if blah.html is also present in the zip?

Thanks for a useful tool.

Comment only
11 Mar 2007 ams mas  
08 Mar 2007 Jeremy Steveson

Thanks for providing. Please provide an intel r2007a mac version of the compiled windows & linux app for the dup code art of the metric.

While any metric isn't perfct I need to manage a large amount of code from many coder and this helps me get a first pass at code I need to look at.

Thanks again.

02 Mar 2007 cecil hoarau

je cherche un logiciel pour tabler des commande, et pouvoir me servir de procedé de mathlab.thank 's very much.

28 Feb 2007 pari pari

very good example explain

Comment only
06 Feb 2007 Lizbeth Paredes Aguilar

I would like, to acoupled of the toolbox fuzzy with comandes matlab, into to simulink for the desing fuzzy control process.

30 Jan 2007 Hung Tran Khanh

Could you tell me the way to generation a numer using the Gaussian random is, please?

Comment only
29 Jan 2007 varun bharadwaj  
19 Jan 2007 igor psychotron  
09 Jan 2007 rahul chowdam  
09 Jan 2007 Bishwajit Aich


03 Jan 2007 senthil kumar  
24 Dec 2006 Jahanzeb Rajput

It runs on MATLAB 7, how can it check the metrics of the m-files generated using oler versions of MATLAB correctly?

21 Dec 2006 mojtaba mahdavinia

i am student university sharif.i want formations related simulation bldc.thnks

19 Dec 2006 abrham Hailu


16 Dec 2006 Liyth nissirat

it is great

13 Dec 2006 Bashir Bala

very good,and excellent

11 Dec 2006 kamatchi priya  
05 Dec 2006 mohamed fazal

excellent one, improve it...

04 Dec 2006 sathya niranjan

good one... keep it up

21 Nov 2006 Hung nguyen

very good

16 Nov 2006 egdy za  
14 Nov 2006 wilmer salazartrujillo

necesito un ejemplo de simplex en matlab

Comment only
14 Nov 2006 wilmer salazartrujillo

necesito con urgencia el desarrollo de un problema de simplex en matlab.

Comment only
13 Nov 2006 indu a

Good it helped me a lot

29 Oct 2006 maria arrabal  
19 Oct 2006 C. S.


18 Oct 2006 chandan chandan maity

very good

Comment only
16 Oct 2006 Brian Hui

It is pretty nice. However, when I used it, the one it downloaded is not the one I picked. There is one file shift between them. Is it just me or everyone gets this problem?

16 Oct 2006 suresh t  
13 Oct 2006 ibrahim oudjani

I need a matlab code for face detection.thenk's

Comment only
07 Oct 2006 azam gholizadeh

i want transmit nmr spectrum in matlab help me

07 Oct 2006 azam gholizadeh  
06 Oct 2006 reza sahebi

its very good

Comment only
04 Oct 2006 Muhammad Farrukh Subhani

I am getting following error with todays download (4/10/2006)

??? XMTOK takes one input, one output.

Error in ==> Improve Codes\private\generateStats>getLineCounts at 83
[unused,bptok] = xmtok(f);

Error in ==> Improve Codes\private\generateStats at 29
[stats(i,1).lines,stats(i,1).comments] = getLineCounts(file);

Error in ==> codemetrics at 31
stats = generateStats(workingDir);

Comment only
23 Sep 2006 duojia chen


Comment only
31 Aug 2006 oudjani ibrahim  
16 Aug 2006 Ronny Meza  
27 May 2006 Animesh Gain


25 May 2006 arun gk  
22 May 2006 namnam namnami  
21 May 2006 kunle oni

hi i got your mail on the mathlab central and i will like to know you

Comment only
19 May 2006 Satyanand singh

Really it is good.I wish you all the best

17 May 2006 Celalettin Yýlmaz  
17 May 2006 JR P

I don't find this to be particularly useful myself, but it is worthwhile code to have around.

We seem to have a lot of whiners here. THIS IS FREE CODE PEOPLE! IF YOU DON'T LIKE IT, DON'T USE IT!

This code is on the File Exchange for free. It's not part of a MATLAB Official Release, and is not held to the same "high standards". I can write any peice of garbage code I want (not that this code is garbage) that is useful to someone out there and post it here at the File Exchange. Geez... you didn't just pay $1k for this code, so stop feeling as if this code should be tailored specifically to your liking.

BTW, I found this code easy to follow when reading through the *.m files, but maybe that's because I actually understand MATLAB, unlike *some* people.

17 May 2006 teena joseph

I would like to know how an image can be loaded in the Matlab prompt

Comment only
04 May 2006 Norbert Marwan

Does not work on a system running another OS than MSWindows, because it contains a compiled programme. The advantage of Matlab is, I guess, that scripts, functions and toolboxes are working on every platform, independent on the OS, isn't it?

Moreover, I fully agree with Oliver.

02 May 2006 Oliver Chapman

On one hand, I can't complain too much, the code appears to do what it is suppose to.

But, particularly a ~15 module function should be written such that it is easy to tell what it is doing and how.

It took me 45 minutes to dig down to discover the undocumented feature in "mlint" that calculates complexity.

This code doesn't even pass that test with an index of 13.

Each module should have a summary of which modules it calls and who calls it. Variables should be defined. Spaces should follow commas.

All these points, and more, are covered in the Style Guidelines in your White Paper section.

This looks like cowboy code and I've wasted too many years digging thru this type. It really is cheaper to write it well first, from well written requirements and with quality documentation.

If MathWorks employees write this style of code, how can I be assured the primary functions in MatLab are well written?

07 Apr 2006 Art Croucher

Of course no single measure can accurately summarize all code, as our guy whose analysis routine scored a 107 will tell you. But this tool gives my group a common starting point to discuss code.

For a lot of what we do in Matlab, Halstead might be better (feature request!)

"In particular, the complexity of code with a high ratio of calculational logic to branch logic may be more accurately assessed by Halstead measures than by Cyclomatic Complexity, which measures structural complexity."

31 Mar 2006 Matthew Simoneau

Eduard, it should now be doing the right thing with respect to methods. Let me know if we're still missing something.

Urs, mdf is compiled only for Windows, and now Linux. On other platforms the report won't be able to include "cloned code", but the rest of it should work. We're looking into opening the source code for this, but it dives into parts of the parser to find equivalent code (even if it's not identical) and we need to be sure we're not revealing any trade secrets.

Darren, yes this code will only run newer versions of MATLAB. It uses some experimental features that were only introduced recently.

Heinrich and Dave and John, we relaxed the regular expression we are using to detect examples. plot4 will now be OK.

As to the value of these metrics, nobody is claiming that they are the ultimate judge of quality. They are just here to suggest areas where your code might be improved and to show how any submission compares to others on the File Exchange.

Thank you all for taking the time to send your feedback and please keep it coming.

Comment only
28 Mar 2006 Jiro Doke

I tried to improve the score on some of my m-files using this, and ultimately decided that there's not always a direct correlation between good code and good score, as many have mentioned here. I think it would be useful if the SCORE and PERCENTILE RANKING were removed. These are often subjective, so assigning a number to the "goodness" may not be the way to go. However, the raw results from each criteria may still be helpful (the example check should be improved). Then based on those results, people can make their own judgement on the usefulness of the code.

Comment only
28 Mar 2006 John D'Errico

Looking more deeply into these metrics, I note that cyclomatic complexity penalizes better codes. A comparison of two codes which are identical, except that one has extensive error checks for bad data, will yield a poor complexity score for the code which attempts to check for problems. Every test for problems should reduce the resulting score. I wanted to verify this fact, but I cannot since this submission only runs if you have PC matlab. Sigh.

28 Mar 2006 John D'Errico

I'm lukewarm about these metrics. These are not perfect at all, but they can be improved. Any single number measures of code will tend to show only the broad tendencies anyway. And they can easily miss subtle variations, for example, in how an example is flagged. Your examples may get missed just because of use of the phrase "example usage", instead of just "example".
Mlint is another problem, since mlint in the newer releases will catch more problems in your code. Since these metrics will use our own (sometimes older version of) mlint, they need not be even truly representative of the website metrics.
As for cyclomatic complexity, I can't even pronounce it. ;-) But it does seem ironic that "code metrics" got a poor score itself for cyclomatic complexity.

Comment only
27 Mar 2006 Robert Finch

I personally find this submission to be a wonderful addition to the FEX. Be able to quickly see the number of lines of code and % percent of comments on a directory of code is wonderful. Anyway who manages a large number of matlab programmers will see the benefit of having this available. As for those that hate metric, think of it has a relative thing. If you see someone consistently with little comments, then you need to check it out and see if their comments are on par. Let's not think in absolutes.

27 Mar 2006 Duane Hanselman

For folks who write good code, these code metrics are not much use. However, they do identify poorly coded submissions. Folks who don't bother to check mlint messages or care about name clashes get flagged by these metrics. The "cyclomatic complexity" metric is the one I don't fully understand. Sometimes it just isn't possible to get a low (good) number.

Comment only
27 Mar 2006 dave martin

As stated before, this metric misses things, like examples for example. I hate programs that purport to tell me how to program better anyway.

27 Mar 2006 Heinrich Acker

I did not run this submission, but looked at the results for other submissions. It produces wrong results sometimes for the help section. For example, look at the comments of the recent 'plot4' submission. It has an example, but code metrics tells it hasn't.

24 Mar 2006 Darren Engwirda

Doesn't seem to work on R13. Problem with regexp and 'Tokens'...

I agree with Us. Codemetrics suck. They don't measure anything useful and can give the impression there is something wrong with a submission when there isn't.

This is not an attack on the author, I'm sure your submission does exactly what it says it does for R14.

Comment only
24 Mar 2006 urs (us) schwarz

the core (mdf.?) is hidden - and this is simply very insulting and just a no-go to this community!
personally, i am extremely disenchanted by this submission - as i have been very disenchanted by the recently introduced file/code metrics to begin with since it is:

- absolutely (sic!) useless in the realm of ML if ever you understood anything about its visionary concept...
- promotes mediocrity (sic!) at best... that is: at best...
- most of the time computes, extracts, and displays plain false, inscrutable, mostly unintelligible, and absolutely misleading information (particularly for a newcomer) about a contribution

as i said: i am VERY disenchanted

24 Mar 2006 Eduard van der Zwan

This is just what I was looking for. Just one quation. Under filename clashes it only shows the clashes with the functions them selfs e.g. gravity.m: work/unitfun/gravity.m and not the real clashes e.g. for @foo/vertcat.m. Should i perhaps change my path or is this a bug?

31 Mar 2006

* Compute cloned code also on Linux.
* Relax "Example" checking.
* Ignore "Readme.m" in filename clashes.

31 Mar 2006

Further relax the "example" detection.

02 Aug 2006

FXDOWNLOADS and FXSEARCH has been added.

02 Aug 2006

FXDOWNLOADS and FXSEARCH code has been added.

02 Aug 2006

FXDOWNLOADS and FXSEARCH has been added.

26 Apr 2010 1.1

Deleted fxsearch and fxdownload functionality which is not working anymore.

01 Sep 2016

Updated license

Contact us