Recall that the logical array produced by the expression "M>1" has true elements everywhere that M has a value greater than 1. The find function allows us to find the row and column positions of all the true elements in an array. What about the second line of code above? Well it turns out that MATLAB has other convenience functions that operate on logical arrays. ![]() Therefore, the first line of code here implicitly creates an array that's true for all the entries we care about and then counts the number of true entries. One convenience for us is that if we sum a logical array, it gives us a count of how many true values it contains. In this case, it becomes a 2-by-2 matrix of true and false values that's true everywhere M has a value greater than 1. The result of this expression is a logical array the same size as the original matrix. First, we are performing the logical operation M>1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |