Why do we usually use M,N,P to indicate dimensions?

taken to indicate the dimension of the array m, n, p. the meaning of these letters I guess that m - main n -??? p - page?

Answers (2)

They are just variables when used like this:
[m,n,p] = size(rand(2,3,4))
m holds the first dimension (the number of rows)
n holds the second dimension (the number of columns)
p holds the third dimension of the array, think about it like the number of pages

4 Comments

thank you, but I would like to know why m,n,p instead of r,c,p ...
abcdefghijklMNoPqrs...
That's it. Just consecutive letters typically used to denote integers. (O is skipped due to its similarity to 0).
just variables, no particular meaning, use the variables you like the most
Historical habit in mathematics, just like using the beginning of the alphabet to represent constants and using the end of the alphabet to represent variables.

Sign in to comment.

m and p gives the number of rows and columns

2 Comments

as I know m and n gives the number of rows and columns, is any advantage to use p for columns due the best perfomance?
No. The programming language doesn't care which variable name you use, but you will lose efficiency from people reading your code and attempting to figure out what your names mean. If you are going to use non-traditional names, use names that are self-explanatory.

Sign in to comment.

Categories

Tags

Asked:

on 28 Jul 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!