Using the diag and commands!
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 29 Mär. 2013
Hint: if you have N rows, then the elements on the diagonal are (N+1) elements apart.
2 Kommentare
Walter Roberson
am 29 Mär. 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.
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!