-8

I was writing a code on MATLAB where by mistake, I wrote this line:

x = rand(1:3)

And I got the following output:enter image description here

Can someone explain to me what is going on here? Is it a 3D matrix? Or something else?

1 Answer 1

5

It creates a 3 dimensional random array x = rand(1:3) is same as

x = rand([1,2,3]) 

you can change the values such that

x = rand([3,2,3]) will create a 3x2x3 elements of random array

Here is a well defined explanation of what rand function does

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.