MATLAB: Create a 3×3 cell array with random numbers
random number array
hi, i have the follow variable mx = {randi(50,600,1); randi(360,60,1); randi(50,60,1)} this is a 3×1 cell array. I want to create a 3×3 cell array with random numbers. how can i do that?
thanks
Best Answer
I guess you don't mean scalar numerics, but rather numeric arrays of arbitrary size. I answered in a previous question of yours that you should consider working more with numeric arrays... these can be converted easily to cell arrays later.
For this question, as I also answered previously, one possibility is to create your numeric array and then usemat2cell to convert this into a cell array of numeric arrays. Something like this:
mat2cell(randi(50,20,10),[2,6,12],10)
In your example your threerandi calls are over different ranges. Note that there is no possibility to create one numeric array using just one call torandi but with different ranges.
Best Answer