Question & Answer: Write your own function for calculation of the number of combinations of r items out of n items. You need…..

matlab
please write a program in matlab
Write your own function for calculation of the number of combinations of r items out of n items. You need to use your own factorial function, and then use this function for calculation: n! 7l
suppose there is no built in function for factorial in matlab.come up with ur own function for factorial

Write your own function for calculation of the number of combinations of r items out of n items. You need to use your own factorial function, and then use this function for calculation: n! 7l

Expert Answer

 

Answer:

Factorial funtion to find number of possibilities.

Matlab Code Screenshot:

Sample Output:

Code to Copy:

% Read the input as cobminations from keybaord
r=input(‘Enter number of Combinations :’);

% Read the input as total from keybaord
n=input(‘Enter number of items :’);

% Calculate the number of combinations as per the Given formula.
fact1=factorial(n);
fact3=factorial(r);
sub=factorial(minus(n,r));
total=fact1 / (sub * fact3);

% Display the output.
fprintf(“Total number of possibilities are: % in”,total);

Still stressed from student homework?
Get quality assistance from academic writers!