我用这个子程序,创建大小为N如何使用Excel VBA创建标识矩阵?
Sub IdMatrix()
Dim i As Integer, j As Integer, N As Integer
N = 5
For i = 1 To N
For j = 1 To N
If i = j Then
Cells(i, j) = 1
Else
Cells(i, j) = 0
End If
Next j
Next i
End Sub
有没有更好的办法的单位矩阵?简单的一个可能?
我认为这个问题应该转移到http://codereview.stackexchange.com – NatNgs