RowsColumns

Here are two VERY simple functions that are “leftovers” from when I used octave. In octave there were calls for getting the number of rows and columns from a matrix. In Matlab this doesn’t seem to exist so here are my own versions:

Rows:

function r = rows(A);

%
%    r = rows(A) – return number of rows in matrix
%
%   A      –       matrix
%
%   r       –       number of rows
%

r = size(A,1);

 

download_rows

 

Columns:

function c = columns(A);

%
%    c = columns(A) – return number of columns in matrix
%
%   A       –       matrix
%
%   c       –       number of columns
%

c = size(A,2);   %return the number of columns in a matrix

 

download_columns