FALL_19_ASSIGN-2 Solve the following problems in your command window after turning your ‘diary’ on. Then submit your command window outputs. Please make sure that your code prints: Name, ID, Seat #, Assign_2 in the first line of your command window. 1-22: Type one line in command window so that it displays answer to the following question: A total of 4217 eggs have to be packed in boxes that can hold 36 eggs each. How many eggs will remain unpacked if every box that is used has to be full? 2-11: Using the colon (:) symbol, create a row vector (assign it to a variable named Time) in which the first element is 0, the spacing is 1, and the last element is 20. 2-12: Using the linspace command, create a row vector (assign it to a variable named Fours) with nine elementsthat are all 4. 2-19: Create a row vectors A=4:3:13 and a column vector B=[14:- 2:6]’. Then only using the name of the vectors (A and B), create the following: (a) A row vector C that is made from the elements of B followed by the elements of A. (b) A column vector D that is made from the elements of A followed by the elements of B.
1.
A total of 4217 eggs have to be packed in boxes that can hold 36 eggs each. How many eggs will remain unpacked if every box that is used has to be full?
To find the number of eggs that will remain unpacked, we first need to find the total boxes needed for packing 4217 eggs
number of boxes = 4217/36 = 117.14 (since we are interested only in full boxes, we take integer value only which obtained by using the function fix)
number of full boxes = 117
number of unpacked eggs can be obtained by subtracting the total number of eggs by number of eggs present in 117 boxes
unpacked eggs = 4217 - 117*36 = 4217 - 4212 = 5
2. Using the colon (:) symbol, create a row vector (assign it to a variable named Time) in which the first element is 0, the spacing is 1, and the last element is 20.
Time = (0:1:20); where the sequence starts from 0, ends at 20 and step size is 1
3. Using the linspace command, create a row vector (assign it to a variable named Fours) with nine elements that are all 4.
Fours = linspace(4,4,9) ; generates a row vector with 9 elements that are all 4 . Since the spacing between the elements are 0 all 9 elements will be 4.
4. Create a row vectors A=4:3:13 and a column vector B=[14:- 2:6]'
(a) A row vector C that is made from the elements of B followed by the elements of A.
C = [B', A]
Since B is a column vector, so to get the row vector we transpose B
Since C is a row vector made from the elements of B followed by the elements of A, first elements of B will occur and then A
In the above command, B will be transposed so as to produce the row vector and these elements will be concatenated with the elements of A which is another row vector and as a result C will be a row vector containing elements of B followed by elements of A.
(b) A column vector D that is made from the elements of A followed by the elements of B.
D = [A';B]
Since A is a row vector, so to get the column vector we transpose A
Since C is a column vector made from the elements of A followed by the elements of B, first elements of A will occur and then B
In the above command, A will be transposed so as to produce the column vector and these elements will be concatenated with the elements of B which is another column vector and as a result D will be a column vector containing elements of A followed by elements of B.
Get Answers For Free
Most questions answered within 1 hours.