create a 3x3 cell array with random numbers

hi, i have the follow variable mx = {randi(50,600,1); randi(360,60,1); randi(50,60,1)} this is a 3x1 cell array. I want to create a 3x3 cell array with random numbers. how can i do that?
thanks

 采纳的回答

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 use mat2cell 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 three randi calls are over different ranges. Note that there is no possibility to create one numeric array using just one call to randi but with different ranges.

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by