辅导program编程、讲解Java,c/c++程序设计
- 首页 >> Matlab编程 Octave Assignment 2 Due Friday, April 2, 2021
Resources:
Consult the following resources and any others that you find to discover how to perform all necessary
Octave commands. If after reading through the following websites, you still need some help and
direction, please email me. For this reason, I would strongly suggest you NOT wait until the last
minute to complete this assignment.If you go to this site’s main page, there are numerous other resources, too.
Assignment:
1. Write an m-file SCRIPT that will perform the following steps:
(a) Ask for the input of a square matrix A.
(b) Check the order to see if it is square (before continuing to the next steps).
(c) Find the determinant of A.
(d) Find the inverse of A, if it exists.
(e) Find the eigenvalues of A and their corresponding eigenvectors.
2. Write two separate m-file FUNCTIONS that will accomplish the tasks described below. In
each file, there should be two inputs: (1) A square matrix A and (2) a positive integer n.
The single output will be the sum described below.
(a) 1st Function: Write a FOR loop to find the sum: A + A2 + A3 + · · · + An
.
(b) 2nd Function: Write a WHILE loop to find the sum: A + A2 + A3 + · · · + An
.
(c) For extra credit, choose a third type of control statement to use in a function file for
the output given above. Make sure to document (in the diary file) running this third
function for all instances described in parts 2. and 3. below.
3. In the discussion board on D2L, under the topic ”Octave Assignment 2”, write or respond
to at least one post. For example, your post can include (a) suggestions on additional
resources to find help understanding how to complete this assignment, (b) questions for your
classmates on how to troubleshoot an issue programming, (c) answers to your classmates
relevant questions or (d) any other relevant subject matter.
What to turn in:
1. Turn in the three m-files (1 script file, 2 functions) described above.
2. Turn in a diary (text file) of you running the script file FIVE times. The first time, use a
non-square matrix. The second time, use a square singular (not invertible) matrix. The third
time, use an invertible matrix. For the last two times, use the matrices A1 and A2 described
below.
3. Using a diary file to record your progress, run each of the functions four times: (i) A = A1,
n = 10, (ii) A = A1, n = 25, (iii) A = A2, n = 10, (iv) A = A2, n = 100.
4. Extra Credit (As described above in Assignment 2(c).) Turn in the additional function file
and repeat Part 3 (i - iv) immediately above for the additional function file.
Matrices A1 and A2:
Let m equal the number of entries in your last name. Let A1 be the m × m matrix
>>A 1= ones(m) - m*eye(m).
Let A2 be the 3 × 3 matrix with the (1, 1) being the integer corresponding to the position of your
first letter of your last name in the alphabet (i.e., the letter A is 1, the letter B is 2, etc.) and the
next 8 entries are the digits of your student ID number.
For example, if my name were Demo Student and my student ID was 12345678, then (using my
last name) S is the 19th letter and m = 7.
Resources:
Consult the following resources and any others that you find to discover how to perform all necessary
Octave commands. If after reading through the following websites, you still need some help and
direction, please email me. For this reason, I would strongly suggest you NOT wait until the last
minute to complete this assignment.If you go to this site’s main page, there are numerous other resources, too.
Assignment:
1. Write an m-file SCRIPT that will perform the following steps:
(a) Ask for the input of a square matrix A.
(b) Check the order to see if it is square (before continuing to the next steps).
(c) Find the determinant of A.
(d) Find the inverse of A, if it exists.
(e) Find the eigenvalues of A and their corresponding eigenvectors.
2. Write two separate m-file FUNCTIONS that will accomplish the tasks described below. In
each file, there should be two inputs: (1) A square matrix A and (2) a positive integer n.
The single output will be the sum described below.
(a) 1st Function: Write a FOR loop to find the sum: A + A2 + A3 + · · · + An
.
(b) 2nd Function: Write a WHILE loop to find the sum: A + A2 + A3 + · · · + An
.
(c) For extra credit, choose a third type of control statement to use in a function file for
the output given above. Make sure to document (in the diary file) running this third
function for all instances described in parts 2. and 3. below.
3. In the discussion board on D2L, under the topic ”Octave Assignment 2”, write or respond
to at least one post. For example, your post can include (a) suggestions on additional
resources to find help understanding how to complete this assignment, (b) questions for your
classmates on how to troubleshoot an issue programming, (c) answers to your classmates
relevant questions or (d) any other relevant subject matter.
What to turn in:
1. Turn in the three m-files (1 script file, 2 functions) described above.
2. Turn in a diary (text file) of you running the script file FIVE times. The first time, use a
non-square matrix. The second time, use a square singular (not invertible) matrix. The third
time, use an invertible matrix. For the last two times, use the matrices A1 and A2 described
below.
3. Using a diary file to record your progress, run each of the functions four times: (i) A = A1,
n = 10, (ii) A = A1, n = 25, (iii) A = A2, n = 10, (iv) A = A2, n = 100.
4. Extra Credit (As described above in Assignment 2(c).) Turn in the additional function file
and repeat Part 3 (i - iv) immediately above for the additional function file.
Matrices A1 and A2:
Let m equal the number of entries in your last name. Let A1 be the m × m matrix
>>A 1= ones(m) - m*eye(m).
Let A2 be the 3 × 3 matrix with the (1, 1) being the integer corresponding to the position of your
first letter of your last name in the alphabet (i.e., the letter A is 1, the letter B is 2, etc.) and the
next 8 entries are the digits of your student ID number.
For example, if my name were Demo Student and my student ID was 12345678, then (using my
last name) S is the 19th letter and m = 7.