Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 Create a MATLAB script file named as: Lab3_Probleml.m. The program should start by generating and displaying the following matrices: 1 5 -8 -4

image text in transcribedimage text in transcribedimage text in transcribed

Problem 1 Create a MATLAB script file named as: Lab3_Probleml.m. The program should start by generating and displaying the following matrices: 1 5 -8 -4 2 6 -7 -3 3 7 -6 A = 4 8 -5 -2 104 B = -192 1-173 168 141 150 -139] 123 -115] Afterwards, the program should create the following matrix P by extracting and using the elements from the already created matrices A and B. You are allowed to use as many instances of A and B as you like, but you should only use a single line of code to create matrix P. If you need to, you may transpose some rows and/or columns from A and B. -6 P= -5 L-139 141 150 168 1 5 104) All three variables and their contents should be displayed on the Command Window upon running the program. Problem 2 Create a MATLAB script file named as: Lab3_Problem2.m. Upon running the program, MATLAB should prompt the user to enter a matrix with at least two rows and two columns. This matrix should be stored in a variable of your choice. The matrix, after being entered, should be displayed in the Command Window (either by calling the variable, or not suppressing the output, or using the disp function; your choice). Next, the program should display the following message in the Command Window, using a single disp function: The entered matrix has n rows and m columns. where n and m hold the number of rows and columns of the matrix that the user entered, respectively. Specific MATLAB functions to extract the matrixs dimensions and proper conversion to string data type are needed. After the previous message, MATLAB should let the user know that one of the matrix's columns needs to be deleted, and prompts the user to specify the column number to be removed. This scalar numeric value is then stored in another variable; do not show this value in the Command Window (suppress the output). Finally, MATLAB should rely on the indexing command to remove the specified column from the matrix. The new matrix is then displayed on the Command Window (either by calling the variable, or not suppressing the output, or using the disp function; your choice). Safely assume that the user will be inputting a matrix during the first prompt (2x2 or larger), and a valid scalar number corresponding to an existing column during the second prompt. Even though better approaches in the implementation of the above program may cross your minds, note that you are only allowed to use MATLAB functions and operators that we have reviewed up to this point in the course. Problem 3 Create a MATLAB script file named as: Lab3_Problem3.m. Upon running the program, MATLAB should prompt the user to enter either a scalar value or a vector value (any amount of elements is allowed). After the user enters the value, it should be stored in a variable x. Next, the following mathematical equation should be evaluated by MATLAB, using a single line of code. The result should be stored in a variable y. -2.5x e V2x y(x) 2.5x cos(5x) x3 + 2 4. Finally, the resulting scalar (or vector) in y should then be displayed in the Command Window through the disp function, in a message that reads: The result is: y(x) = y where y is the variable holding the scalar (or vector) contents. Carefully decide where the element-wise operator is needed when coding the equation. Large penalties will be applied for using the element-wise operator where it is not needed! Also using more sets of parenthesis than needed will incur penalties (recall order of arithmetic operations to help you decide this). Problem 1 Create a MATLAB script file named as: Lab3_Probleml.m. The program should start by generating and displaying the following matrices: 1 5 -8 -4 2 6 -7 -3 3 7 -6 A = 4 8 -5 -2 104 B = -192 1-173 168 141 150 -139] 123 -115] Afterwards, the program should create the following matrix P by extracting and using the elements from the already created matrices A and B. You are allowed to use as many instances of A and B as you like, but you should only use a single line of code to create matrix P. If you need to, you may transpose some rows and/or columns from A and B. -6 P= -5 L-139 141 150 168 1 5 104) All three variables and their contents should be displayed on the Command Window upon running the program. Problem 2 Create a MATLAB script file named as: Lab3_Problem2.m. Upon running the program, MATLAB should prompt the user to enter a matrix with at least two rows and two columns. This matrix should be stored in a variable of your choice. The matrix, after being entered, should be displayed in the Command Window (either by calling the variable, or not suppressing the output, or using the disp function; your choice). Next, the program should display the following message in the Command Window, using a single disp function: The entered matrix has n rows and m columns. where n and m hold the number of rows and columns of the matrix that the user entered, respectively. Specific MATLAB functions to extract the matrixs dimensions and proper conversion to string data type are needed. After the previous message, MATLAB should let the user know that one of the matrix's columns needs to be deleted, and prompts the user to specify the column number to be removed. This scalar numeric value is then stored in another variable; do not show this value in the Command Window (suppress the output). Finally, MATLAB should rely on the indexing command to remove the specified column from the matrix. The new matrix is then displayed on the Command Window (either by calling the variable, or not suppressing the output, or using the disp function; your choice). Safely assume that the user will be inputting a matrix during the first prompt (2x2 or larger), and a valid scalar number corresponding to an existing column during the second prompt. Even though better approaches in the implementation of the above program may cross your minds, note that you are only allowed to use MATLAB functions and operators that we have reviewed up to this point in the course. Problem 3 Create a MATLAB script file named as: Lab3_Problem3.m. Upon running the program, MATLAB should prompt the user to enter either a scalar value or a vector value (any amount of elements is allowed). After the user enters the value, it should be stored in a variable x. Next, the following mathematical equation should be evaluated by MATLAB, using a single line of code. The result should be stored in a variable y. -2.5x e V2x y(x) 2.5x cos(5x) x3 + 2 4. Finally, the resulting scalar (or vector) in y should then be displayed in the Command Window through the disp function, in a message that reads: The result is: y(x) = y where y is the variable holding the scalar (or vector) contents. Carefully decide where the element-wise operator is needed when coding the equation. Large penalties will be applied for using the element-wise operator where it is not needed! Also using more sets of parenthesis than needed will incur penalties (recall order of arithmetic operations to help you decide this)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Multidimensional Array Data Management In Databases

Authors: Florin Rusu

1st Edition

1638281483, 978-1638281481

More Books

Students also viewed these Databases questions

Question

Define Management by exception

Answered: 1 week ago

Question

Explain the importance of staffing in business organisations

Answered: 1 week ago

Question

What are the types of forms of communication ?

Answered: 1 week ago

Question

Explain the process of MBO

Answered: 1 week ago