I'm taking a course that uses matlab, and for one assignment, we need to write a function that, among other things, counts the number of rows and columns in any given numeric matrix. The thing is that we're not allowed to use(adsbygoogle = window.adsbygoogle || []).push({}); anybuilt-in functions. No x = size(mat). No length(mat). It all has to be done with loops.

I was thinking of writing 2 while loops; one to count the number of columns and one to count the number of rows. The only problem is that I have no idea how to check whether or not a specified row or column exists. I tried the 'exist' function, but that will only tell me if the matrix exists.

any help is appreciated.

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Counting the number of rows/cols in a matrix with Matlab

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - Counting number rows | Date |
---|---|

Count from MatrixForm in mathematica | Sep 25, 2012 |

Mathematica Calculating length from pixel count | May 11, 2012 |

Defining a counting function in mathematica | Aug 10, 2011 |

Counting Occurrences in a 2D Array with MATLAB | Jul 2, 2011 |

Matlab - count how many times a number occurs | Aug 17, 2010 |

**Physics Forums - The Fusion of Science and Community**