How to make one element in a matrix the same for other elements?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
What I mean by the question is the following:
Say I have matrix A and my A(2,1) = constant
Is there a way that I can write A(2,1)=A(2,1)=A(2,3) and so on?
2 commentaires
Réponse acceptée
Stephen23
le 1 Mai 2016
Modifié(e) : Stephen23
le 1 Mai 2016
>> x = 1;
>> y = 2;
>> N = 4; % size of the matrix
>> A = eye(N) * x;
>> A(1+1:1+N:end) = y;
>> A(1+N:1+N:end) = y;
>> A(1) = 8;
>> A(end) = 10
A =
8 2 0 0
2 1 2 0
0 2 1 2
0 0 2 10
Plus de réponses (1)
Roger Stafford
le 1 Mai 2016
You want every other element in the second row to be set equal to the first element?
A(2,:) = A(2.1);
Or do you have other elements to be set? Your description is not very clear.
0 commentaires
Voir également
Catégories
En savoir plus sur Operating on Diagonal Matrices 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!