Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This problem deals with operations on matrices of numbers. To represent matrices

ID: 3889444 • Letter: T

Question

This problem deals with operations on matrices of numbers. To represent matrices, we will use a list of lists of numbers, where the ith list corresponds to the ith row of the matrix. For example, the list

corresponds to a 3 × 3 matrix whose first row has the numbers 3, 17 and 32, whose second row has the numbers 2, 10 and 4 and whose last row has the numbers 7, 5 and 9.

For a list of lists of this kind to qualify as a matrix, every row must have an equal number of columns. Define a function

that returns true or false depending on whether or not the given list of lists of integers represents a "good" matrix.

Define a function

that will generate a new matrix from a given one by multiplying each element by the given number. For example, you should see the following kind of interaction based on this function:

Explanation / Answer

x = [1 0 2 4] & [0 0 1 i]

x =

0 0 1 0

>> x = [1 0 2 4] | [0 0 1 i]

x =

1 0 1 1

In addition, you can run a cumulative boolean "or" or boolean "and" across all the elements of a matrix or vector. If v is a vector or matrix, any(v) returns true if the real part of any element of v is non-zero; all(v) returns true if all the elements of v have non-zero real parts.

You can also compare two vectors element-wise with any of six basic relational operators:

< less than

> greater than

== equal to

~= not equal to

<= less than or equal to

>= greater than or equal to

For example:

>> x = [1 2 3 4 5] <= [5 4 3 2 1]

x =

1 1 1 0 0

Relational operators are particularly important in programming control structures.

x = [1 0 2 4] & [0 0 1 i]

x =

0 0 1 0

>> x = [1 0 2 4] | [0 0 1 i]

x =

1 0 1 1

In addition, you can run a cumulative boolean "or" or boolean "and" across all the elements of a matrix or vector. If v is a vector or matrix, any(v) returns true if the real part of any element of v is non-zero; all(v) returns true if all the elements of v have non-zero real parts.

You can also compare two vectors element-wise with any of six basic relational operators:

< less than

> greater than

== equal to

~= not equal to

<= less than or equal to

>= greater than or equal to

For example:

>> x = [1 2 3 4 5] <= [5 4 3 2 1]

x =

1 1 1 0 0

Relational operators are particularly important in programming control structures.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote