From http://hi.baidu.com/kingmmxtj/blog/item/dfec6bf809bb3a09d8f9fdc2.html
Advance Description: The factorial function in MATLAB is factorial (N). Please help
Factorial; regression question: Since MATLAB was used, the biggest problem found is that it is too intelligent, and the bigger problem is that I think it should be so intelligent ...... so the most common mistake is "inner ".
Matrix dimensions must agree! Open factorial. I want to calculate the formula as = D! /(S! * (D-S )!) (That is, get s in combination D) The current initialization code is as follows:D = 7; S =; As = factorial (d)/(factorial (s) * factorial (D-S ))No problem with the formula, right? Running or error! Take a closer look at D as a matrix with only one element 7, and s as a matrix of 1x7. I thought MATLAB would automatically expand the elements (such as running reshape). I am wrong, modify as follows: add definitionD = [
D];Replace d in the formula with D, OK, run, and Error Matrix
Dimensions must agree! This is a classic error. The calculation of all matrix response elements must be added with dot. Modify againAS1 = factorial (d)./(factorial (s). * factorial (D-S ))This time I finally got OK. Remember one thing:The input variable of MATLAB is a matrix, and the matrix dimensions involved in the calculation must correspond!
| Reply
I would like to raise a question:
X = 0.0: 0.1: 2 * PI;
Y = 0.0: 0.1: 2 * PI;
Z = x * Cos (y) * sin (x) + y * sin (y) * Cos (X );
An error occurred while running this step! Why? Error message: "??? Error Using ==> mtimes
Inner matrix dimensions must agree ."
Please advise !!
| Reply
Reply xiaozhang8712:
It should be Z = x. * Cos (Y). * sin (x) + Y. * Y. * sin (Y). * Cos (X ~