How would I check to see if the number of rows in one matrix are equal to the number of rows in another matrix?
3 次查看(过去 30 天)
显示 更早的评论
I'm trying to write a function which will compare two matrices. Prior to this comparison I want my function to error check the entered matrices to ensure that the two matrices have the same number of rows. I know I will use and if/else statement and an error message, but what would the code look like for the check? Thank you!
0 个评论
回答(2 个)
Star Strider
2016-11-2
Use the size function to get the size of the vector or matrix. The first dimension are the number of rows, so for matrix ‘A’:
nr_rows = size(A,1);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!