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.m308 chars13 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.m374 chars14 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