make a random 100-by-100 matrix in matlab

You can create a 100-by-100 matrix of random numbers in Matlab by using the rand function and a for loop. Here's how:

main.m
% set the size of the matrix
matrix_size = 100;

% initialize the matrix
random_matrix = zeros(matrix_size);

% loop through the matrix and assign a random number to each element
for row_index = 1:matrix_size
    for col_index = 1:matrix_size
        random_matrix(row_index,col_index) = rand();
    end
end
308 chars
13 lines

This code generates a 100-by-100 matrix of random numbers between 0 and 1. The zeros function is used to initialize the matrix with all zeroes, and then the for loops iterate through each element of the matrix and assign a random number to it using the rand function.

You can also use the randi function if you want a matrix of random integers. For example:

main.m
% set the size of the matrix and the range of integers
matrix_size = 100;
integer_range = [1 100];

% initialize the matrix
random_matrix = zeros(matrix_size);

% loop through the matrix and assign a random integer to each element
for row_index = 1:matrix_size
    for col_index = 1:matrix_size
        random_matrix(row_index,col_index) = randi(integer_range);
    end
end
374 chars
14 lines

This code generates a 100-by-100 matrix of random integers between 1 and 100. The randi function is used to generate the random integers.

gistlibby LogSnag