Engr 0012: Introduction Engineering Computing Programming Assignment 16 Tuesday
ID: 3781284 • Letter: E
Question
Engr 0012: Introduction Engineering Computing Programming Assignment 16 Tuesday April 19 aware MATLAB Problem: You developing a new product that it hopes will rival and team charge of developing have hired by have been Inc as a assigned new sof supplant engineering tool for design and analysis. You to the development the handling portion of the software package. round of Background: The basic matrix operati that you need to perform in this first Matrix addition: note: matrix addition is only permitted ifIA] and [Bj have the same dimensions a warming should be displayed if the addition cannot be performed Matrix subtraction: Ccl, where cu au note: matrix subtraction is only permitted if [A] and [B] have the same dimensions a warning should be displayed if the subtraction cannot be performed Matrix multiplication: 4M,NLBw note: matrix multiplication is only permitted if BN,P has the same number of rows as [Altar has columns. The resulting matrix has dimension MxP a warning should be displayed if the multiplication cannot be performed Matrix element by element multiplication: P [Al.N[Bl, where cy a by element multiplication is only permitted if [BlNxP has the same number of rows and columns [A]MaN a warning should be displayed if the multiplication cannot be performed Assignment: Design and code acprogram that has the following functions: a) A function that will read the data file name and its contents. The first row of the data file have two entries: the number of rows in the matrix followed by the number of columns in the matrix, the remainder the file will contain the (real, floating point matrix elements, row by row. The function should return the number of rows and columns in the matrix as well as the What does this function need from the calling function to do its job? (nothing why? What does this function need from the user to do its job? thing-what?) What will the function return to the calling program, if successful?Explanation / Answer
Part A
1. This function does not need anything from its calling function because it asks the user to give the file name within the function itself. And all the operations involved in parsing the file are done using the file itself and nothing else.
2. The function needs the "full file name along with the absolute path" from the user in order to correctly locate the file on the drive and open it to read it and parse it correctly
3. The function will return three things - (a) no. of rows in a matrix ( integer type), (b) no. of columns in a matrix ( integer type) and (c) The matrix ( a 2D float type array)
It gets returned using "return" keyword. For e.g. "sample_matrix" is the variable name which is a 2D array of size determined by the input no. of rows/columns. so to return we use - reurn sample_matrix. Since we are returing the array, it automatically returns its size( no. of rows/columns) and its elements.
Part B
1. This function does not need anything from its calling function because the function works based on user input of choice which is done within the function.
2. This function returns the user choice to the calling function. It will basically return the char type variable which will contain the value of user input. For example - return 'A' will mean that user has chosen A option. retunr 'Q' means tha user has chosen to quit.
Part C
1. It will need 6 things from the calling function which are as follows -
a. no. of rows in matrix 1
a. no. of rows in matrix 1
b. no. of columns in matrix 1
c. no. of rows in matrix 2
d. no. of columns in matrix 2
e. elements of matrix 1
f. elements of matrix 2
2. It will return three things -
a. no. of rows of resultant matrix after addition (int type)
b. no. of columns of resultant matrix after addition( int type)
c. elements of resultant matrix after addition( 2D array float type)
Part D
1. The function differ only in the respect that the operation performed on each element will involve "-" instead of "+"
2. It will need 6 things from the calling function which are as follows -
a. no. of rows in matrix 1
a. no. of rows in matrix 1
b. no. of columns in matrix 1
c. no. of rows in matrix 2
d. no. of columns in matrix 2
e. elements of matrix 1
f. elements of matrix 2
3. It will return three things -
a. no. of rows of resultant matrix after addition (int type)
b. no. of columns of resultant matrix after addition( int type)
c. elements of resultant matrix after addition( 2D array float type)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.