Write a function that retuns logical true of vector or matrics or scaler is empt
ID: 3925500 • Letter: W
Question
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 SOLUTIONExplanation / Answer
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.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.