File Exchange

## Discrete matrix distribution and it's parameters for educational purpose.

version 1.0.0.0 (1.25 KB) by
Various parameters of 2D discrete variable

Updated 25 Sep 2008

Example - dismat(50,5,6) creates 5x6 probability matrix and gives various parameters. Freshers can see and appreciate the work load in the computation. oo.dat will be created with results.

### Cite As

Mathan Chandran (2021). Discrete matrix distribution and it's parameters for educational purpose. (https://www.mathworks.com/matlabcentral/fileexchange/21575-discrete-matrix-distribution-and-it-s-parameters-for-educational-purpose), MATLAB Central File Exchange. Retrieved .

John D'Errico

I was thinking, I should explain why the code fragment in my previous review is so poor.

1. There are NO comments. My recommendation is that a good programmer in Matlab should aim for somewhere near to one line of comment for every line of code. You don't need to hit that goal all of the time, but its not a bad goal to have. Why is this a good goal? A matrix language like Matlab can be a dense one. You can pack a lot of functionality into a single line of code. So your comments should explain what has been done, and why. Those comments should help you to debug your code a year from now if you learn about a bug, or if you need to make a change.

2. The variable names are numerically sequential. DON'T DO THIS. Instead, use intelligent, mnemonic names. Intelligently chosen names are self documenting. They help you to read the code, to understand it.

I could probably go on with this, but the points above are a good start. As it is, this small code fragment is the code from hell. If you are a student or a novice programmer and you see code like this, do yourself a favor and run like crazy in the other direction.

John D'Errico

No useful help to anyone in the world. What does this do? Why does it do it? How will it help anyone?

No H1 line. No error checking. Virtually the only internal comment line is this:

%success--------------------------------------------------------------

Will that be of any help to someone who is reading the code? No.

Any "freshers" who bother to look at this will be wasting their time.

How about the coding style? I'm sorry, but it is MISERABLE. Here is a representative piece of it. I could swear that the author learned to code from Marco.

y1 = unidrnd(a,n1,n2);
y2 = sum(sum(y1));
y3 = sum(sum(y1'));
y4 = y1/y2;
r = unidrnd(100,1,n2);
r = sort(r);
c = unidrnd(100,n1,1);
c = sort(c);
y5 = [r;y4];
c = [0;c];
y6 = [c,y5];
y7 = sum(y4')';
y8 = sum(y4);
y7 = [0;y7];
y8 = [0,y8,1];
y9 = [y6,y7];
yy = [y9;y8];
y100 =yy;

This is NOT how you want to teach anybody to program, nor what they should learn from. If I could rate this a -1, I would do so.

Jos x@y.z

Complete lack of comments and help, so where is the educational value? Also, do not zip a single m-file.

##### MATLAB Release Compatibility
Created with R2008a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux