A = rand(5)
B = diag(diag(A).^2)
C = A.^2
C(logical(eye(size(C))))=0
===回答完毕===
小数不太好看,可以把随机值规定在1-8
代码如下:
A = round(8*rand(5))
B = diag(diag(A).^2)
C = A.^2;
C(logical(eye(size(C))))=0
A = rand(5)
B = diag(diag(A).^2)
C = A.^2
C(logical(eye(size(C))))=0
===回答完毕===
小数不太好看,可以把随机值规定在1-8
代码如下:
A = round(8*rand(5))
B = diag(diag(A).^2)
C = A.^2;
C(logical(eye(size(C))))=0