Write a function called GenMat that takes a 2D array of numbers inMat and produces an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function called GenMat that takes a 2D array of numbers inMat and produces an array called outMat. The function copies the input array inMat to the output variable outMat and then performs the following operations on outMat in order: 1. Delete the first and last columns. Store the information from these columns in variables to be used later. 2. Sum the elements of the first row in inMat and place the answer in the last row (all entries) of outMat (i.e. overwrite any existing values). 3. Sum of elements of the last row in inMat and place the answer in the first row (all entires) of outMat (i.e. overwrite any existing values). 4. Append the sum of the two deleted columns from part 1 as the new last column of outMat. 5. Append the product of the two deleted columns from part as the new first column of outMat. The input argument (inMat) iand output argument (outMat) are both n x m (numeric) arrays. Restrictions: Use colon() operator and end operator. Do not use loops or if else statements. For example: For the given 4x5 inMat inMat-[12 1 14 9 3; 2 6 24 1 2; 1 17 41 6 90; 4 9 68 71 5]; On calling GenMat outMat GenMat (inMat) produces, outMat [36 = 4 90 20 157 6 17 39 157 157 15 24 1 4 41 6 91 39 39 9] In outMat first ([12 2 1 4]) and last ( [3 2 90 5]) columns of inMat are deleted. Then the first row of outMat is replaced with the sum of last row elements in inMat (4+9+68+71+5 =157) and last row of out Mat is replaced with the sum of first row elements in inMat (12+1+14+9+3 = 39). Finally, the sum of the deleted columns ([12 2 1 4]) + ([32,905 Vate Windo ([15 4 91 9]) is appended to become the last column and their product ([12 2 1 4])*([3 2 90 5]) = ([36 4 90 20]) is appended to become the first column. Go to Settings to act Write a function called GenMat that takes a 2D array of numbers inMat and produces an array called outMat. The function copies the input array inMat to the output variable outMat and then performs the following operations on outMat in order: 1. Delete the first and last columns. Store the information from these columns in variables to be used later. 2. Sum the elements of the first row in inMat and place the answer in the last row (all entries) of outMat (i.e. overwrite any existing values). 3. Sum of elements of the last row in inMat and place the answer in the first row (all entires) of outMat (i.e. overwrite any existing values). 4. Append the sum of the two deleted columns from part 1 as the new last column of outMat. 5. Append the product of the two deleted columns from part as the new first column of outMat. The input argument (inMat) iand output argument (outMat) are both n x m (numeric) arrays. Restrictions: Use colon() operator and end operator. Do not use loops or if else statements. For example: For the given 4x5 inMat inMat-[12 1 14 9 3; 2 6 24 1 2; 1 17 41 6 90; 4 9 68 71 5]; On calling GenMat outMat GenMat (inMat) produces, outMat [36 = 4 90 20 157 6 17 39 157 157 15 24 1 4 41 6 91 39 39 9] In outMat first ([12 2 1 4]) and last ( [3 2 90 5]) columns of inMat are deleted. Then the first row of outMat is replaced with the sum of last row elements in inMat (4+9+68+71+5 =157) and last row of out Mat is replaced with the sum of first row elements in inMat (12+1+14+9+3 = 39). Finally, the sum of the deleted columns ([12 2 1 4]) + ([32,905 Vate Windo ([15 4 91 9]) is appended to become the last column and their product ([12 2 1 4])*([3 2 90 5]) = ([36 4 90 20]) is appended to become the first column. Go to Settings to act
Expert Answer:
Answer rating: 100% (QA)
Here is the implementation of the GenMat function in MATLABOctave based on the given re... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
Use the definition of the derivative, f'(x) = lim (x+h) - to find the derivative of f(x) = f'(x)=help (formulas) h0 h Problem 3. (1 point) Use the definition of the derivative, f'(x) = lim f(x + h) -...
-
is a branch of computer science that focuses on creating computer systems or computer-controlled machines that have an ability to perform tasks usually associated with human intelligence. Natural...
-
1. A project has the following cash flow diagram,calculate: $50 $100 2 $20 20 $120 a) The present worth of the project, giving that MARR-15%. b) The simple payback period( payback with no interest)...
-
Rafael Espinal's leadership approach is best categorized as what type of leadership? spiritual adaptive authentic servant
-
1. How might different types of office design influence employee social interaction, collaboration, and creativity? Should these be encouraged even in organizations without an innovative culture? 2....
-
Bindra Company reported retained earnings at December 31, 2013, of $340,000. Bindra had 200,000 shares of common stock outstanding throughout 2014. The following transactions occurred during 2014. 1....
-
The 6-ft-long column has the cross section shown and is made of material which has a stress-strain diagram that can be approximated by the two line segments. If the column is pinned at both ends,...
-
Capitalization of Interest the following three situations involve the capitalization of interest. Situation I On January 1, 2010, Columbia, Inc. signed a fixed-price contract to have Builder...
-
2. (30 points) Here is an SML mergesort program: fun merge ([], ys) = ys | merge (xs, []) = xs merge (x::xs, y::ys) = if xy then x::merge (xs, y::ys) else y::merge (x::xs, ys) = ([], []) fun split []...
-
Use the data in VOLAT.RAW for this exercise. (i) Confirm that Isp500 = log(sp500) and lip = log(ip) appear to contain unit roots. Use Dickey-Fuller tests with four lagged changes and do the tests...
-
A. Describe the pricing strategy used by the Adidas company in the global market!. And state (if any) which countries, is the pricing strategy used different? Explain! B. In your opinion, what are...
-
In simple regression, the geometric interpretation is to fit a line that best describes the relationship between x and y. What is the geometric interpretation of multiple regression when there are...
-
What are time-series data? Why would we ever be interested in looking at timeseries data? Give some examples of time-series data.
-
In multiple regression, we can test the significance of the individual regression coefficients by using a t-test, or we can test the joint significance of the coefficients by using an F-test. Is it...
-
Dechow, Inc., issued \(\$ 225,000\) of \(8 \%\), 15 -year bonds at 96 on July 1,2009 . Interest is payable semiannually on December 31 and June 30. Through June 30, 2014, Dechow amortized \$3,000 of...
-
For each of the following situations, indicate the liability amount, if any, that is reported on the balance sheet of Heller, Inc., at December 31, 2014. a. Heller owes \(\$ 110,000\) at year-end...
-
The water flow rate through the siphon is 5 L/s, and the pipe diameter is 2.5 cm. Compute the maximum allowable height, h, so that the pressure at point A is 235.8 Pa. Assume the flow is...
-
What is the order p of a B + -tree? Describe the structure of both internal and leaf nodes of a B + -tree.
-
Use the 1-norm to determine the condition number of A: || 1 2 1 1 12 402 1 22
-
Imagine that I have integrated the autonomous IVP using some method and at step n I have a value yn. Under what conditions will explicit Euler and predictorcorrector yield the same result for y n+1 ?...
-
Solve the IVP with y(0) = 0 using ode45. dy dt = e~! (4.10.1)
-
Find the time it takes for a transverse wave to travel along a transmission line from one tower to another one \(300 \mathrm{~m}\) away. Assume the horizontal component of the cable tension as 30,000...
-
Fill in the Blank. In the wave-solution \(w(x, t)=w_{1}(x-c t)+w_{2}(x+c t)\), the first term represents the wave that propagates in the __________ directions of \(x\). conditions
-
What is a wave equation? What is a traveling-wave solution?
Study smarter with the SolutionInn App