How about mysize(A) = if ndims(A) == 1; return length(A), 1; else return size(A); end
Though this is kind of lying, since a true 1-dimensional vector doesn't have a second dimension. If it really makes your life easier to treat vectors as n-by-1 column matrices like Matlab does, you can currently use A'' to get this, but that may not be the case indefinitely. On Tuesday, April 15, 2014 3:40:14 AM UTC-7, Peter wrote: > > Given a vector A defined in Matlab by: > > A = [ 0 > 0 > 1 > 0 > 0 ]; > > we can extract its dimensions using: > > size(A); > > Apparently, we can achieve the same things in Julia using: > > size(A) > > Just that in Matlab we are able to extract the dimensions in a vector, by > using: > > [n, m] = size(A); > > irrespective to the fact whether A is one or two-dimensional, while in > Julia A, size (A) will return only one dimension if A has only one > dimension. > > How can I do the same thing as in Matlab in Julia, namely, extracting the > dimension of A, if A is a vector, in a vector [n m]. Please, take into > account that the dimensions of A might vary, i.e. it could have sometimes 1 > and sometimes 2 dimensions. >