One simple question..
Let’s suppose in Matlab we have a variable: numEntries = 8
I know “ones” is used to create “1’s matrixes” but what’s the result of the following?
W = ones(1:numEntries);
And,if possible,where I can find a good reference about matrixes in Matlab? I looked in official documentation but it is not so clear to me.
Thank you very much
onescreates a matrix of ones.onesworks for any number of dimensions, however if you specify only one argument, you’ll get a square matrix of ones of that size. Otherwise, you’ll get aN-dimensional matrix of ones,Nbeing the number of arguments you give toones.If
numEntriesis 8,1:numEntriescreates a 1×8 vector1 2 3 4 5 6 7 8. This vector being given as input toones, you’ll get a 8-dimensional matrix of ones, in which the size of 1st dimension (vertical) is 1, the size of 2nd dimension (horizontal) is 2, the size of third dimension is 3, and so on, until the 8th dimension, that has size of 8.% To check sizes of each dimension of
W:% To calculate the total number of elements in
W:% Edit: to get the number of elements in
W,numel(W)is faster thanprod(size(W)):