how to identify empty , non-empty char matrix condition?
21 次查看(过去 30 天)
显示 更早的评论
I have a matrix "A" with size 4x8 char and having values:
'01:04:00'
'01:03:00'
' '
'01:01:00'
I want to identify the index of empty char. I.e. 3rd one.
I tried,
% first one
A == ""
% second one
A == ''
% third one
isempty(A)
% forth one
isspace(A)
% fifth one
A == ' '
% sixth one
A == " "
% everything shows zero output.
Can anyone please help?
Any help will be greatly appriciated.
0 个评论
采纳的回答
Stephen23
2022-7-18
编辑:Stephen23
2022-7-18
M = [...
'01:04:00'
'01:03:00'
' '
'01:01:00'];
strcmp('',cellstr(M)) % CELLSTR removes trailing whitespace characters.
cellfun(@isempty,cellstr(M)) % CELLSTR removes trailing whitespace characters.
all(M==32,2) % match space character only.
all(M==' ',2) % match space character only.
all(isstrprop(M,'wspace'),2) % match any whitespace character.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!