Tutorial: Eigenvalue problem

Tutorial: MATLAB

Estimate the eigenvalue and eigenvectors

clear; close all;

A = [45 30 -25; 30 -24 68; -25 68 80];

disp('Eigvalue and vector of A (MATLAB):');
[eigVec,eigVal]=eig(A)
eigvalues=diag(eigVal)

Exercise 1: MATLAB

Download the tutorial source file

Fill-In the blanks.

function [Q, R] = QRdecomp_student(A)  
% Factorization of given matrix [A] into Upper triagular [R] and orthogonormal [Q]
% Using HouseHold Matrix
% Input: A (nxn)
% Output: Q (nxn), R (nxn)
    
    % Initialization
    n = size(A,1);
    I=eye(n);
    H=zeros(n,n);
    R=A;
    Q = I;    
    
    for j = 1:n-1                
        % Step 1. Create vector [c]
        % [YOUR CODE GOES HERE]
        % c = _______________;   
        

        % Step 2. Create vector [e]
        e=zeros(n,1);
        % [YOUR CODE GOES HERE]
        % e = _______________;
        

        % Step 3. Create vector [v]
        % [YOUR CODE GOES HERE], HINT: use norm(c,2)
        % v = _______________;
    

        % Step 4. Create matrix [H]
        % [YOUR CODE GOES HERE]
        % H = _______________;
        
        % Step 5. Update [Q], [R]
        Q = Q*H;
        R = H*R;
    end

end % end of function

Run the code and check the answer with MATLAB's eig(A)

Exercise 2: Eigenvalue in C-Programming

Download the tutorial source file

Create the function that returns the estimated eigenvalues

Exercise 3: Eigenvector in C-Programming

Last updated

Was this helpful?