Question: part a) Modify the matlab code below to find the number of possibilities (through combinations and permutations) that 3 different awards can be awarded to

part a) Modify the matlab code below to find the number of possibilities (through combinations and permutations) that 3 different awards can be awarded to 4 students through the following cases: case I: one award goes to one student, case II: two awards goes to one student, case III: three awards goes to one student.

part b) Modify the matlab code below to find the number of possibilities (through combinations and permutations) that 5 different awards can be awarded to 8 students through the following cases: case I: one award goes to one student, case II: two awards goes to one student, case III: three awards goes to one student.

Matlab code:

close all; clear all; % clear all variables, close all windows with plots clc

tot_students = 5; num_awards = 3; students=[1:tot_students];

C3_alldifferent = combnk(students,num_awards); [rcomb1,ccomb1] =size(C3_alldifferent);

C3_alldifferent % Display ALL of the combinations n choose k

perm_nk1 = []; for ip=1:rcomb1; perm_nk_ip = perms(squeeze(C3_alldifferent(ip,:))); perm_nk1 = [perm_nk1; perm_nk_ip]; end perm_nk1 [rperm1,cperm1] = size(perm_nk1)

% Next generate those cases where one student gets 2 awards C2_alldifferent = combnk(students,num_awards-1) [rcomb2,ccomb2] =size(C2_alldifferent) % Determine the number of combinations (rows) by determining the size of the array

perm_nk2 = []; for ip=1:rcomb2; perm_nk_ip = perms(squeeze(C2_alldifferent(ip,:))); perm_nk2 = [perm_nk2; perm_nk_ip]; end perm_nk2

pnk2_onerA = [perm_nk2(:,1) perm_nk2(:,1) perm_nk2(:,2)]; pnk2_onerB = [perm_nk2(:,1) perm_nk2(:,2) perm_nk2(:,1)]; pnk2_onerC = [perm_nk2(:,2) perm_nk2(:,1) perm_nk2(:,1)]; pnk2_onerepeat = [pnk2_onerA; pnk2_onerB; pnk2_onerC];

perm_nk2 = pnk2_onerepeat; perm_nk2 % show results [rperm2,cperm2] = size(perm_nk2); rperm2

% Next generate those cases where one student gets 3 awards

C1_alldifferent = combnk(students,num_awards-2) perm_nk3 = [C1_alldifferent(:) C1_alldifferent(:) C1_alldifferent(:)]; [rperm3,cperm3] = size(perm_nk3);

ALL_permutations = [perm_nk1; perm_nk2; perm_nk3] [rperm_tot,cperm_tot]= size(ALL_permutations); rperm_tot

rperm_tot_check = rperm1+rperm2+rperm3

figure; hist(ALL_permutations(:),100); title(' Histogram of all permutations')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!