BetaCodeShareBeta

by Code Solutions Project

Simple solutions for common problems

Description:Random square matrix from size
Matlab
MagRag
function [ A ] = randomMatrix( siz )
    A = rand(siz,siz)*10;
end

Input example

2

Output example

[[0.32 0.9]
 [0.45 0.23]]
View version's history

Other implementations

C/C++
void fillMatrix(int matrix[DIM][DIM]) {
  int i, j;
  for(i = 0; i < DIM; i++) {
    for(j = 0; j < DIM; j++) {
      if(sopa[i][j] == ZERO) {
	sopa[i][j] = random(CHAR_MIN, CHAR_MAX);
      }
    }
  }
}
×Oh snap! Something wrong