0

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?

ggael
  • 28,425
  • 2
  • 65
  • 71
user3222184
  • 1,071
  • 2
  • 11
  • 28

1 Answers1

2

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

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • thank you for answering. I have two more question. 1) how do you set incremental values of k ( in this case you have 0.5 in the interval)? – user3222184 Feb 13 '14 at 03:27
  • 2), in your 4 line, you have 'ones(2,1)*k', if my matrix is 3x3, do I change the to 'ones(3,1)*k'? thank you very much – user3222184 Feb 13 '14 at 03:28
  • 1
    @user3222184 to change `xtick` after xlabels you can use `set(gca, 'xtick', [0:5]);`. If you have 3 resulting eigenvalues , than you need `ones(3,1)*k`. – Marcin Feb 13 '14 at 03:57