Question: Matrix Operations 4 0 Points / 1 0 per Part In this exercise, you will first use for loops or while loops to create a
Matrix Operations Points per Part
In this exercise, you will first use for loops or while loops to create a matrix, and then you will practice some matrix operations and verify some properties for matrices. You may need the following commands for this exercise.
The command invAreturns the inverse of A when A is invertible.
The command A returns the transpose of A when all entries in A are real numbers.
You also need to be familiar with both for loops and while loops.
for loop
The for loop executes a group of statements in a loop for a specified number of
times.
for index initialval:endval
statements
end
for index initialval:step:endval
statements
end
Note: The first for loop has an implicit step of
while loop
The while loop executes an expression and repeats the execution of a group of statements in a loop while the expression is true see the example in the handout
while expression
statements
end
Compare for loop i and for loop ii in the template file.
Do you have the same output for matrix A
For an n x n matrix A calculate the number of FLOPs additions used in each for loop. Express the number of FLOPs in terms of n for each for loop. Be sure to show your work for for loop ii and simplify your final answer.
Which for loop uses fewer FLOPs?
Practice while loops: Rewrite both for loop i and for loop ii using while loops only. You should get the same output as part A If not, check your code in while loops.
Note: DO NOT forget to put semicolons in commands in loops causes excessive printing
Check some properties for matrix multiplications and do the following operations using matrix A from A:
Create a matrix B with size n x n whose entries are random integers between and
Try AB and BA by setting them to ABBA.
Note: Only one command will work. Leave the one that works and give a reason why the other does not work.
Create a matrix C with size n x n whose entries are random integers between and
Calculate AC and CA and set them to AC and CA respectively. Are they the same? Why or why not?
Calculate Aeyen and eyenA and set to AI and IA Are they the same? Why or why not?
Check some properties involving the inverse and transpose of a matrix.
Use matrix A from A and find the inverse of A inverseA using invA Is A invertible?
Let
Create matrix D and find the inverse of D using
invD and
RREF of D Write the code with exactly two lines using rref to calculate the inverse of D
Calculate the following in MATLAB.
invinvD does it equal to D Generalize your observation.
Create matrix
invDE invDinvE invEinvD which two give you the same result? Finish the generalization.
invDinvD are they the same? Finish the generalization.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
