# How to present the determinant and eigenvalue using FprintF function

3 vues (au cours des 30 derniers jours)
Jonas Morgner le 8 Mai 2022
Commenté : Jonas Morgner le 9 Mai 2022
m1 = [7 3; 3 -1] % Matrix
% B.
syms L % Symbol representing λ
% C
I = eye(2) % Identity matrix
% D
LI = I * L % Multiplying λ with the Identity matrix
% E
m2 = m1 - LI % Subtracting matrix 1 with lI
d2 = det(m2) % Finding determinant
d3 = solve(d2) % Solving the polynomial function of the determinant
How can I present the results of d2 and d3 using the fprintf function?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

William Rose le 8 Mai 2022
You can display the symbolic d2 and d3 using fprintf() as shown below. Note that d2 is a string variable, so I use "%s" in the fprintf() command, and d3 is numeric, so I use "%d". I could use "%.1f" or a similar variation for displaying d3, if I wanted decimal places.
syms L % Symbol representing λ
m2 = [7 3; 3 -1] - L*eye(2);
d2 = det(m2); % Finding determinant
d3 = solve(d2); % Solving the polynomial function of the determinant
fprintf('Determinant=%s\n',d2);
Determinant=L^2 - 6*L - 16
fprintf('d3=%d, %d\n',d3)
d3=-2, 8
or as follows
fprintf('d3=%d, %d\n',d3(1),d3(2))
d3=-2, 8
Try it.
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Jonas Morgner le 9 Mai 2022
Awesome thank you very much :)

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Linear Algebra dans Help Center et File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by