Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the code that would satisfy the above problem? There are two MATLAB functions we will use for combinations and permutations, nchoosek and perms.

image text in transcribed

What is the code that would satisfy the above problem?

There are two MATLAB functions we will use for combinations and permutations, nchoosek and perms. Look up the help files for these two functions. Test them out with the following: nchoosek ([1 3 51,2) nchoosek ('abc', 2) perms ([1 3 5]) perms ('abc') Note that the perms function only finds all the permutations of size n from a set of size n. It always returns n! elements. What if we wanted the elements of Pan,k), choose k from n permutations? You will have to do this calculation yourself. Here is how you can use the MATLAB functions to find the permutations choose k from n. In your textbook look at Figure 2-6. Note that for each combination we can find all the permutations for that combination. So, first find all the combinations using nchoosek. The number of rows will be the number of combinations. Then for each row, find the permutations. You can concatenate the results to make one long vector. Make a script to answer the following questions. At the beginning of the script have the following: %% MATLAB Combinations and Permutations & Your Name %ECE Math II 8% clean up the environment clear all; close all; clc; format compact; Before each answer make sure you have a new section like: %% Problem 1 1. Use MATLAB to generate all the permutations of pick 3 from {a,b,c,d). Using the nchoosek and perms functions you should be able to do this in around 6 lines of code. Have MATLAB display the results. 2. Use MATLAB to generate all the permutations of pick 3 from 'abacab'. Display the number of permutations. Don't display the permutations, just the coutn. How many unique permutations are there? Hint: use the function unique. What is ABACAB? 3. Use MATLAB to generate all the permutations of pick 3 from 'duckduckgoose'. Don't display them. Also generate all the permutations of pick 3 from 'gosling! Don't display them. What is the intersection of these two sets? Only display the intersection, There are two MATLAB functions we will use for combinations and permutations, nchoosek and perms. Look up the help files for these two functions. Test them out with the following: nchoosek ([1 3 51,2) nchoosek ('abc', 2) perms ([1 3 5]) perms ('abc') Note that the perms function only finds all the permutations of size n from a set of size n. It always returns n! elements. What if we wanted the elements of Pan,k), choose k from n permutations? You will have to do this calculation yourself. Here is how you can use the MATLAB functions to find the permutations choose k from n. In your textbook look at Figure 2-6. Note that for each combination we can find all the permutations for that combination. So, first find all the combinations using nchoosek. The number of rows will be the number of combinations. Then for each row, find the permutations. You can concatenate the results to make one long vector. Make a script to answer the following questions. At the beginning of the script have the following: %% MATLAB Combinations and Permutations & Your Name %ECE Math II 8% clean up the environment clear all; close all; clc; format compact; Before each answer make sure you have a new section like: %% Problem 1 1. Use MATLAB to generate all the permutations of pick 3 from {a,b,c,d). Using the nchoosek and perms functions you should be able to do this in around 6 lines of code. Have MATLAB display the results. 2. Use MATLAB to generate all the permutations of pick 3 from 'abacab'. Display the number of permutations. Don't display the permutations, just the coutn. How many unique permutations are there? Hint: use the function unique. What is ABACAB? 3. Use MATLAB to generate all the permutations of pick 3 from 'duckduckgoose'. Don't display them. Also generate all the permutations of pick 3 from 'gosling! Don't display them. What is the intersection of these two sets? Only display the inter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions