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

2. In Lab 3A we will be using eigs() to find eigenvalues and eigenvectors of a m

ID: 3890361 • Letter: 2

Question

2. In Lab 3A we will be using eigs() to find eigenvalues and eigenvectors of a matrix. Review the documentation and demonstrate how you would find the eigenvalues and eigenvectors of a matrix, B, in MATLAB: http://www.mathworks.com/help/matlab/ref/eigs.html 3. The debugger is helpful tool for working all of the errors out of your code. Follow the link: http://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and- features.html to read about debugging a MATLAB program. Then answer the following questions: a. How do you set a breakpoint? b. After setting a breakpoint, how do you use it?

Explanation / Answer

2)

For any matrix to find the eigen values and eigen vectors

* The matrix must be a square matrix

* determinant is not equal to zero

To find the eigen values and eigen vectors by solving through book is very har when compared to solving using matlab.

Because there are many inbuilt function for various operations on matrices and so the calculation of eigen vectors and eigen values also have functions they are:

e = eig(A)

This returns a column vector containing the eigen values of square matrix A

e = eig(A, 'matrix')

This returns the eigen values in a diagonal matri

[V, D] = eig(A) returns diagonal matrix D of eigen values and matrix V whose columns are corresponding right eigen vectors

[V,D,W] =eig(A)

this returns D,V along with left eigen vectors W

Now we can see a small example illustrating the calculation of eigen values and eigen vectors of a NxN matrix B

B = rand(3,3)

[V,D] = eig(B);

This returns the diagonal matrix D and the eigen vectors V

3)

a) How do you set a breakpoint ?

Break points pause the execution of a MATLAB program so that one can examine values which are to be checked.

There are three types of break points

Standard Breakpoints

Conditional Breakpoints

Error Breakpoints

1)

Standard Breakpoint pauses the program at a specified line.

Standard Breakpoint can be set through editor or command function

The function used to set Standard Breakpoint is "dbstop"

Ex: dbstop in myprogram at 5

This means that the program pauses at line 5 every time it is executed

The colour of Standard Breakpoint is Red

2)

Conditional Breakpoints pauses the MATLAB program at a line given adn specified condition is satisfied.

WHenever the condition is satisfied in the line there the program is paused

Ex: dbstop in my program at 6 if n>=543

The colour of the Conditional Break point is yellow.

3)

Error breakpoints pauses the MATLAB program whenever an error is occured

we can directly set these breakpoints through editor

By ysing function also we can set the Breakpoint

Ex: dbstop if error

b)

After setting a breakpoint the program pauses at required conditions or at required time soo then we can debug the code where we set the breakpoint and this breakpoint helps in tracing the code and whenever a Error Breakpoint is set we can know the errors and the variables or reasons for those errors.

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