Saturday, 15 January 2011

Generate a cell of random numbers in MATLAB, how? -



Generate a cell of random numbers in MATLAB, how? -

let want generate 3 matrices of size 3x4 each random entries rand(3, 4). how set them in cell 1x3?

with loop, easy:

a = cell(1, 3); i=1:3 a{i}=rand(3, 4); end

you can store in 3 dimensional array:

a = rand(3,4,3);

access i-th layer with:

a(:,:,i)

matlab random cell-array

No comments:

Post a Comment