Search code examples
matlabmatrixcontrolstransfereigenvalue

How to compute a variable inside a matrix


I have a 2x2 matrix of [ 1 2; k 3],

and k is integer between [0,5].

I want to plot the eigenvalues of this matrix as a function of k in the range of [0,5].

How do I do that?


Solution

  • Have a look at this:

       figure();  
       hold on;      
       for k = 0:5  
            plot (ones(2, 1)*k, eig([ 1 2; k 3]), 'o');   
       end
       grid on;
       xlabel('k'), ylabel('eigenvalue');
    

    enter image description here