Earn Higher Grades With Instant Assignment Help.Ask Question!

Others
(5/5)

shell/program for high-school students to solve questions involving matrices. It will be a MATLAB like tool although extremely limited in its capability and scope.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Description:

                MatShell: A shell/program for high-school students to solve questions involving matrices. It will be a MATLAB like tool (although extremely limited in its capability and scope).

Details:

                The program will behave like an interactive shell where the user can give commands (related to matrices) and see the results. Alternatively, the commands may be written in a script (with .msh extension) which can be passed as a command line argument. If a script is provided, the program will run all the commands given in the script, display corresponding results, and exit. If no script is provided as a command line option, it will enter into the interactive shell mode, where it will wait for user to type a command. For each typed command, it will display a result and wait for the next command. It will remain active until a command to exit the shell is given by the user. MatShell should be able to handle matrices of any size. Following commands are supported:

Commands:

1)       matrix_name = [ matrix values provided as rows separated by semicolons ]

A matrix can be created by providing a name, equal sign, and values of the matrix provided in rows separated by semicolons and enclosed in square brackets. The name of a matrix can only be composed of one or more letters e.g. A and First are valid names but Mat1 is not. The program should internally create a matrix with provided values and remember its name, as it would be used later by the user in other commands. The program should also print the matrix as a signal to user that it got the matrix and is ready for the next command. (Note that this is not really a command but a way to create a matrix.)

The following is how we can create a 2x4 matrix A.

A = [1 2 3 4; 5 6 7 8;]

The program will print the following as soon as the user provides the above command and presses enter.

A =

      1        2        3        4

                     5        6        7        8

                Note that the printed matrix is nicely formatted.

2)       size matrix_name

size command will print the size of the matrix matrix_name as number of rows x number of columns.

Example: (Note A was declared above.)

size A

ans = 4 x 2

3)        isRow matrix_name

isRow command will print yes if the given matrix matrix_name is a row matrix (has a single row), otherwise no.

Example:

isRow A

ans = no

4)       isColumn matrix_name

isColumn command will print yes if the given matrix matrix_name is a column matrix (has a single column), otherwise no.

Example:

isColumn A

ans = no

5)       isRectangular matrix_name

isRectangular command will print yes if the given matrix matrix_name is a rectangular matrix (number of rows and number of columns are different), otherwise no.

Example:

isRectangular A

ans = yes

6)       isSquare matrix_name

isSquare command will print yes if the given matrix matrix_name is a square matrix (number of rows and number of columns are equal), otherwise no.

Example:

isSquare A

ans = no

7)       isDiagonal matrix_name

isDiagonal command will print yes if the given matrix matrix_name is a square matrix whose all non-diagonal elements are 0, otherwise no.

Example:

B = [1 2 3; 4 5 6; 7 8 9;]

B =

      1        2        3

      4        5        6

      7        8        9

isDiagonal B

ans = no

C = [2 0; 0 5;]

C =

      2        0

      0        5

isDiagonal C

ans = yes

8)       isScalar matrix_name

isScalar command will print yes if the given matrix matrix_name is a diagonal matrix whose all diagonal elements are equal to some non-zero constant, otherwise no.

Example:

isScalar C

ans = no

D = [2 0; 0 2;]

D =

      2        0

      0        2

isScalar D

ans = yes

9)       isIdentity matrix_name

isIdentity command will print yes if the given matrix matrix_name is a diagonal matrix

whose all diagonal elements are equal to 1, otherwise no.

Example:

isIdentity D

ans = no

E = [1 0 0; 0 1 0; 0 0 1;]

B =

      1        0        0

      0        1        0

      0        0        1

isIdentity E

ans = yes

10)   isUpperTriangular matrix_name

isUpperTriangular command will print yes if the given matrix matrix_name is a square matrix whose all elements below the diagonal are 0, otherwise no.

Example:

isUpperTriangular E

ans = yes

11)   isLowerTriangular matrix_name

isLowerTriangular command will print yes if the given matrix matrix_name is a square matrix whose all elements above the diagonal are 0, otherwise no.

Example:

isLowerTriangular E

ans = yes

12)   isNull matrix_name

isNull command will print yes if all the elements of the given matrix matrix_name are 0, otherwise no.

Example:

isNull E

ans = no

13)   isSymmetric matrix_name

isSymmetric command will print yes if the given matrix matrix_name is symmetric, otherwise no. A symmetric matrix is a square matrix whose transpose is the same as the matrix itself (A’ = A).

Example:

isSymmetric E

ans = yes

14)   isSkewSymmetric matrix_name

isSkewSymmetric command will print yes if the given matrix matrix_name is skew-symmetric, otherwise no. A skew-symmetric matrix is a square matrix whose transpose is the same as the negative of the matrix. (A’ = -A)

Example:

isSkewSymmetric E

ans = no

15)   areEqual matrix_nameA matrix_nameB

areEqual command is followed by two matrix names; it prints yes if both matrices are the same size and their corresponding elements are the same, otherwise no.

Example:

areEqual A B

ans = no

16)   det matrix_name

det command prints the determinant of the provided matrix matrix_name if it is a square matrix, otherwise it prints an error message “Error: It is not a square matrix”.

Example:

det A

ans = Error: It is not a square matrix.

det B

ans = 0

F = [1 2 3; 2 5 4; 4 3 2;]

F =

      1        2        3

      2        5        4

      4        3        2

det F

ans = -20

17)   isSingular matrix_name

isSingular command prints yes if the determinant of the provided matrix matrix_name is 0. It prints no if the determinant is non-zero and prints an error message “Error: It is not a square matrix” if it is not a square matrix.

Example:

isSingular A

ans = Error: It is not a square matrix.

isSingular B

ans = yes

isSingular F

ans = no

18)   exit

This command will make the interactive shell stop executing

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
879 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
929 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
605 Answers Hire Me