Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the length (count of rows) of this matlab matrix?

Tags:

matlab

I'm quite new to matlab and just need to change a very small thing in a code. I have the following matrix:

ans =

     1     1     1
     1     2     1
     2     1     1
     2     2     2

how to get the count of rows of this ans? it should be 4

like image 676
gurehbgui Avatar asked Jun 21 '13 08:06

gurehbgui


2 Answers

You should use the size function:

nRows = size(myMatrix, 1);  % 1 stands for the first dimension
like image 76
Jean Logeart Avatar answered Sep 18 '22 15:09

Jean Logeart


Just use the size function

size(ans, 1)
like image 24
Dan Avatar answered Sep 16 '22 15:09

Dan