Using the diag and commands!
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So apparently, I can not use the diag and fliplr commands in my program. I have to actually have the program execute the same things just not using those commands. So I am thinking a for loop will need to be used then, but I do not know how. It will always be a 4 x 4 matrix that is stored in MS if that helps.
x=sum(MS);
y=sum(MS');
z=diag(MS);
p=diag(fliplr(MS));
So that is what I had, but I need to change the z and p without using diag and fliplr, and I need to get the same matrix!
Any help is appreciated!
0 commentaires
Réponses (1)
Walter Roberson
le 29 Mar 2013
Hint: if you have N rows, then the elements on the diagonal are (N+1) elements apart.
2 commentaires
Walter Roberson
le 29 Mar 2013
What is z2, and why are you overwriting it on each iteration? And what if there is a 0 on the diagonal ?
Your variable name "ll" looks like the number 11 :(
Hint: if you have N rows, then the elements on the opposite diagonal are (N-1) elements apart.
Voir également
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!