Effacer les filtres
Effacer les filtres

How to assign values in an identity matrix?

11 vues (au cours des 30 derniers jours)
Emanuele Joy
Emanuele Joy le 2 Juin 2018
Modifié(e) : James Tursa le 2 Juin 2018
Simple question, but say I have a 3x3 identity matrix:
I = eye(3)
I =
1 0 0
0 1 0
0 0 1
And I want to change the upper right two elements to, say, 2 and 4:
I =
1 0 2
0 1 4
0 0 1
Is there a function that will allow me to do this?

Réponse acceptée

James Tursa
James Tursa le 2 Juin 2018
Modifié(e) : James Tursa le 2 Juin 2018
For this specific question, simple indexed assignment:
I(1:2,end) = [2;4];
But what is your actual problem?

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays 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