Using the diag and commands!
3 views (last 30 days)
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!
0 Comments
Answers (1)
Walter Roberson
on 29 Mar 2013
Hint: if you have N rows, then the elements on the diagonal are (N+1) elements apart.
2 Comments
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.
See Also
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!