nrows(d), ncols(d)

I found myself continually typing size(A,1) and size(A,2) to get the number of rows and columns. Finally, I just wrote the (very) simple scripts nrows.m and ncols.m. All they do is call the size command but it makes code easier to read…

[cc lang="matlab"]
>> B = zeros( nrows(A), ncols(A) );
[/cc]
The obvious and simple definitions are:
[cc lang="matlab"]
function [n] = nrows(d)
n = size(d,1);
[/cc]

[cc lang="matlab"]
function [n] = ncols(d)
n = size(d,2);
[/cc]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>