problem of matrix operations
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
mahesh chathuranga
le 30 Sep 2013
Modifié(e) : Andrei Bobrov
le 3 Oct 2013
i have a n*n matrix. i want to obtain (row number-column number) matrix.for a 4*4 matrix result should be
[0 -1 -2 -3;
1 0 -1 -2;
2 1 0 -1;
3 2 1 0];
i want to do this for any (n*n) matrix.is there any method to do this.
0 commentaires
Réponse acceptée
Honglei Chen
le 30 Sep 2013
You can do
rownumber = 4
colnumber = 4
bsxfun(@minus,(1:rownumber)',1:colnumber)
Or considering the special form of this matrix, you can just do
toeplitz((0:rownumber-1)',0:-1:-colnumber+1)
Plus de réponses (2)
Azzi Abdelmalek
le 30 Sep 2013
a=rand(4) % Example
n=size(a,1)
bsxfun(@minus,repmat((1:n)',1,n),(1:n))
Voir également
Catégories
En savoir plus sur Resizing and Reshaping 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!