logo for matrixlab-examples.com
[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Welcome Matrixmania Blog
-> Sitemap / Search <-
-> Books <-
Forums and Help
Contact
Basics Quick Matlab Guide
Matlab Tutorial
Matlab Examples
Matlab Flow Control
Boolean Logic
Plots and GUI Matlab 2D Plots
Matlab 3D Plots
Matlab GUI
Applications Calculus
Linear Algebra
Matlab Cookbook I
Matlab Cookbook II
Electrical Calculations
Probability and Stats
Finance Apps
Other Relevant Links
Notes on Computing
Online Calculators
Fun!
Your own Website?
Terms/Policies
leftimage for matrixlab-examples.com

Permutations and Combinations

When we talk of permutations and combinations we often use the two terms interchangeably.
 

In statistics, the two each have very specific meanings.

The permutation of a number of objects is the number of different ways they can be ordered: the position is important. With combinations, one does not consider the order in which objects were placed.

This algorithm (program in Matlab) calculates the number of permutations and combinations of N objects taken D at a time.

The full Matlab code is:

% Clears variables and screen
clear; clc 

% Asks user for input
n = input('Total number of objects: ');
d = input(
'Size of subgroup: ');

% Computes and displays permut. according to basic formulas
p = 1;
for i = n - d + 1 : n
    p = p*i;

end
str1 = [num2str(p) ' permutations'];
disp(str1) 

% Computes and displays combin. according to basic formulas
str2 = [num2str(p/factorial(d)) ' combinations'];
disp(str2)

Example 1:


How many permut. and combin. can be made of the 26 letters of the alphabet, taking five at a time?

We run the code above and enter:

Total number of objects: 26
Size of subgroup: 5

The answer is:

7893600 permutations
65780 combinations


Example 2:


How many different ways can 12 computers be repaired if the workshop can only support 2 at a time?

We run the Matlab m-file above and enter:

Total number of objects: 12
Size of subgroup: 2

The answer (with no doubt) is:

132 permutations

66 combinations


 From 'Permutations and Combinations' to home
 From 'Permutations and Combinations' to 'Probability and Stats' Menu

Top



footer for permutations and combinations page