matlab array length code example
Example 1: matlab length of array
% To get the size of an array, use 'size()'
A = [1, 2, 3, 4; 4, 5, 6, 7];
s = size(A); % [2, 4]
% You can pick a specific dimension
s = size(A, 2); % 4
Example 2: matlab matrix size
d = size(X) % Returns sizes of each dimension of array X in a vector d.
[m,n] = size(X) % Returns the size of matrix X in separate variables m and n.
m = size(X,dim) % Returns the size of the dimension of X specified by scalar dim.