Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called GenMat that takes a 2D array of numbers inMat and produces an array called outMat. The function copies the input

Write a function called GenMat that takes a 2D array of numbers inMat and produces an array called outMat.

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here is the implementation of the GenMat function in MATLABOctave based on the given re... 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_2

Step: 3

blur-text-image_3

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

Numerical Methods With Chemical Engineering Applications

Authors: Kevin D. Dorfman, Prodromos Daoutidis

1st Edition

1107135117, 978-1107135116

More Books

Students also viewed these Programming questions

Question

what is the purpose of an ARP response?

Answered: 1 week ago

Question

Solve the IVP with y(0) = 0 using ode45. dy dt = e~! (4.10.1)

Answered: 1 week ago