How can I create a simple matrix of 4 by 4 using a "for" loop. to make a diagnol of 1's starting from top right to bottom left?

回答(3 个)

Heres a way to do it without a for loop if your interested:
a = ones(4); a = diag(diag(a)); rot90(a)
This might not be too helpful if all of your other elements are not zero.

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

提问:

2013-1-24

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by