Use the function to check if an array is empty: if isempty(u) % do something else % do something else end Answer from Bruno Pop-Stefanov on mathworks.com
🌐
MathWorks
mathworks.com › matlab › language fundamentals › matrices and arrays
isempty - Determine whether array is empty - MATLAB
TF = isempty(A) returns logical 1 (true) if A is empty, and logical 0 (false) otherwise. An empty array, table, or timetable has at least one dimension with length 0, such as 0-by-0 or 0-by-5.
🌐
MathWorks
mathworks.com › system identification toolbox
isempty - Determine whether dynamic system model is empty - MATLAB
isempty(sys) returns a logical value of 1 (true) if the dynamic system model sys has no input or no output, and a logical value of 0 (false) otherwise. Where sys is a frd model, isempty(sys) returns 1 when the frequency vector is empty. Where sys is a model array, isempty(sys) returns 1 when the array has empty dimensions or when the LTI models in the array are empty...
🌐
MathWorks
mathworks.com › matlab › language fundamentals › data types › characters and strings
Test for Empty Strings and Missing Values - MATLAB & Simulink
String arrays can contain both empty strings and missing values. Empty strings contain zero characters and display as double quotes with nothing between them (""). You can determine if a string is an empty string using the == operator. The empty string is a substring of every other string.
🌐
MathWorks
mathworks.com › matlab › software development tools › testing frameworks › write unit tests
matlab.unittest.qualifications.Verifiable.verifyNotEmpty - Verify value is not empty - MATLAB
--> The value has a size of [0 0]. Actual char: 0×0 empty char array ------------------ Stack Information: ------------------ In C:\work\TestForNonemptyCharacterVectorsExample.m (TestForNonemptyCharacterVectorsExample) at 12 · Open Script · Create a test case for interactive testing. testCase = matlab.unittest.TestCase.forInteractiveUse; Verify that the vector [2 3] is not empty. The test passes. verifyNotEmpty(testCase,[2 3]) Verification passed. Test if an array with a zero dimension is not empty.
🌐
Northwestern University
ece.northwestern.edu › local-apps › matlabhelp › techdoc › ref › isempty.html
isempty (MATLAB Functions)
tf = isempty(A) returns logical true (1) if A is an empty array and logical false (0) otherwise.
🌐
Readthedocs
matlab.readthedocs.io › en › draft › empty-arrays.html
Empty arrays — The Black Book of MATLAB 0.0.1 documentation
A common way of encountering empty arrays is by all-false logical indexing in a non-empty array. However note that using a full-size logical matrix for indexing always leads to a 0-by-1 empty array. >> A=rand(2,4) A = 0.0759 0.5308 0.9340 0.5688 0.0540 0.7792 0.1299 0.4694 >> A(A(:,1)>1, :) ...
🌐
Reddit
reddit.com › r/matlab › why does isempty return false?
r/matlab on Reddit: Why does isempty return false?
September 1, 2015 -

I am fairly new to MatLab and am using it to inspect an array of strings to determine whether each element contains a string (specifically, the letter 'a'). When prompting isempty(strfind(TEST(1), 'a')), where TEST(1) does not contain an 'a', it returns FALSE (i.e. 0).

strfind(TEST(1), 'a') returns {[]}

Any help resolving this issue and possibly helping me understand why the result is not TRUE (i.e. 1)?

Edit: Wow thank-you for all of the thorough responses. I'll get back to working on my project tomorrow at work. This looks to be a very supportive community - although the submitted posts seem to get downvoted a lot.

Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › matlab › determine an array or matrix is empty or not in matlab
How to Check Whether an Array or Matrix Is Empty or Not in MATLAB | Delft Stack
February 12, 2024 - One powerful tool for checking whether an array or matrix is empty is the isempty() function. The isempty() function in MATLAB is used to check if a matrix or array is empty.
🌐
Quora
quora.com › How-do-you-check-if-a-variable-is-empty-in-MATLAB
How to check if a variable is empty in MATLAB - Quora
Answer: [code]>> doc isempty [/code]Note the distinction in MATLAB between a variable that exists, but has no meaningful value (apart from the null matrix), and a variable that doesn’t exist at all: [code]>> doc exist >> doc clear >> doc clearvars [/code]An empty variable is often a useful signa...
🌐
MathWorks
de.mathworks.com › matlab › language fundamentals › matrices and arrays
Empty Arrays - MATLAB & Simulink
If no rows in A have nonzero values, then B is an empty array of size 0-by- q. Because B can be an empty array, you can find the number of nonzero rows in A without special handling for the empty case. ... If you want to explicitly check for empty results, you can use the isempty function.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 466276-check-if-the-cells-inside-a-cell-array-are-empty-by-using-if-condition
check if the cells inside a cell array are empty by using if condition - MATLAB Answers - MATLAB Central
January 28, 2019 - The value of 'bboxB' is invalid. Expected input to be of size Mx4 when it is actually size 0x0. Error in bboxOverlapRatio>validateAndParseInputs (line 125) ... https://www.mathworks.com/matlabcentral/answers/466276-check-if-the-cells-inside-a-cell-array-are-empty-by-using-if-condition#comment_713216
🌐
MathWorks
mathworks.com › matlab › programming › classes › construct and work with object arrays
empty - Create empty array of specified class - MATLAB
The empty method creates empty arrays of a given class. For an introduction to empty arrays in MATLAB®, see Empty Arrays. To test if an existing array is an empty array, use isempty.