Using the diag and commands!
Show older comments
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!
Answers (1)
Walter Roberson
on 29 Mar 2013
0 votes
Hint: if you have N rows, then the elements on the diagonal are (N+1) elements apart.
2 Comments
Ryan
on 29 Mar 2013
Walter Roberson
on 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.
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!