Get array dimensions and size of a dimension in Julia – size() Method
Last Updated :
26 Mar, 2020
The size()
is an inbuilt function in julia which is used to return a tuple containing the dimensions of the specified array. This returned tuple format is (a, b, c) where a is the rows, b is the columns and c is the height of the array.
Syntax:
size(A::AbstractArray)
or
size(A::AbstractArray, Dim)
Parameters:
- A: Specified array
- Dim: Specified dimension
Returns: It returns a tuple containing the dimensions of the specified array.
Example 1:
A = [ 5 , 10 , 15 , 20 ]
println(size(A))
B = [ 5 10 ; 15 20 ]
println(size(B))
C = cat([ 1 2 ; 3 4 ], [ 5 6 ; 7 8 ], [ 9 10 ; 11 12 ], dims = 3 )
println(size(C))
|
Output:
Example 2:
A = [ 1 , 2 , 3 ];
println(size(A, 3 ))
B = [ 2 4 ; 6 8 ; 10 12 ];
println(size(B, 2 ))
C = cat([ 10 15 ; 20 25 ], [ 30 35 ; 40 45 ],
[ 50 55 ; 60 65 ], [ 70 75 ; 80 85 ], dims = 3 );
println(size(C, 2 ))
|
Output:
Share your thoughts in the comments
Please Login to comment...