Question

FALL_19_ASSIGN-2 Solve the following problems in your command window after turning your ‘diary’ on. Then submit...

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.

Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
let us create a variable for a row vector a = [1, 4, 1, 3, 2,...
let us create a variable for a row vector a = [1, 4, 1, 3, 2, 5, 0] and calculate the mean value of its elements using the Matlab function ‘mean’ and store this value in variable aMean. Fig. 1 gives the Matlab code to do this. a = [1, 4, 1, 3, 2, 5, 0]; aMean = mean(a); Figure 1: Matlab code – row vector and mean of its elements. Let us now construct a row vector b that...
2. Write the output matrix “v” t = [2:4]; k = [1:3]; v = t.*k –...
2. Write the output matrix “v” t = [2:4]; k = [1:3]; v = t.*k – k.^2 4. Given: D = [1 2 3 4 5 6 7 8 9] (3x3) . Which command will extract the submatrix [1 2 3 4 5 6] (2x3) ? a. D[1:2,1:3] b. D(1,2 ;1,3) c. [D(1:2),D(1:3)] d. D(1:2,1:3) 14. What will be the dimension of matrix B? B=[ones(3) zeros(3) rand(3); 2*eye(9)] 18. Find the value of “C” A=1:2:10; B=linspace(1,5,5); C = length(A)*B(2)+A(5)*B(3); 19....
Part 2: Solve the following problems in MATLAB 1. Fill in the function E = myElim(A,...
Part 2: Solve the following problems in MATLAB 1. Fill in the function E = myElim(A, r_entry, r_pivot, c) to create an m by m elimination matrix ??. Remember that an elimination matrix looks like an identity matrix with one extra entry of ?? in row r_entry and column r_pivot. 2. Fill in the function M = myMult(A, c_pivot) to create an m by m multiplier matrix ??. Remember that a multiplier matrix looks like an identity matrix with the...
For this assignment you need to write a parallel program in C++ using OpenMP for vector...
For this assignment you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is: #pragma...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
Your C program will do the following : Must use at least 2 function prototypes &...
Your C program will do the following : Must use at least 2 function prototypes & definitions . You can also use repetitions , control structures . You re not allowed any type of global arrays, or global variables. You are only allowed to use 2 dimensional arrays. 1. In your main program, create a array of size 7 X 7. 2. Create a function that accepts the empty array. The function will initiate the to zero. Then, the function...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads data from a file and performs regression analysis using polyfit and polyval. The function shall have the following features: The input arguments shall include the file name (string), a vector of integers for the degrees of polynomial fits to be determined, and an optional plot type specifier (‘m’ for multiple plots, ‘s’ for a single plot - default). The data files will be text...
You can complete this assignment individually or as a group of two people. In this assignment...
You can complete this assignment individually or as a group of two people. In this assignment you will create a ​​Sorted Singly-Linked List​ that performs basic list operations using C++. This linked list should not allow duplicate elements. Elements of the list should be of type ‘ItemType’. ‘ItemType’ class should have a private integer variable with the name ‘value’. Elements in the linked list should be sorted in the ascending order according to this ‘value’ variable. You should create a...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT