Write a function that retuns logical true of vector or matri
Write a function that retuns logical true of vector or matrics or scaler is empty %% P2: Check for an empty matrix % Write a function myIsEmpty which takes one input (scalar, vector, matrix, ...) % and returns logical true if the input is empty and false otherwise. % DO NOT USE MATLAB\'s isempty FUNCTION! % % Example: An input of [] should result in the output true. % An input of 1 should result in the output false. % An input of [1, 2] should result in the output false. % An input of [2 3; 4 5] should result in the output false. BEGIN_PRECOND END_PRECOND BEGIN_SOLUTION % Your solution goes here END SOLUTION
Solution
one way is to use numel(input) function which will return number of elements in input. If return value is zero, then given input is empty.
The code will be:
Otherway is to use size(A) function.
