logical2cellstr, cellstr2logical

版本 1.3.0.0 (2.1 KB) 作者: Richie Cotton
Convert from a logical array to a cell array of 'true'/'false' strings and back again.
1.1K 次下载
更新时间 2009/7/10

查看许可证

C = LOGICAL2CELLSTR(TF) takes a logical array TF, and returns a cell array of strings, with the value 'true' wherever TF is true, and 'false' wherever TF is false.

EXAMPLE:
logical2char([true false; false true])
ans =
'true' 'false'
'false' 'true'

TF = CELLSTR2LOGICAL(C) takes a cell array of strings and returns a logical array. Where the input value is 'true' (matched case insensitively), then the corresponding return value is true. Likewise, where the input value is 'false' (matched case insensitively), then the corresponding return value is false. An error is thrown if any other strings are contained in c.

TF = CELLSTR2LOGICAL(C, 1) is as above, but the strings are matched case sensitively.

EXAMPLES:
cellstr2logical({'false', 'True'; 'TRUE' 'FAlsE'})
ans =
0 1
1 0

引用格式

Richie Cotton (2024). logical2cellstr, cellstr2logical (https://www.mathworks.com/matlabcentral/fileexchange/24665-logical2cellstr-cellstr2logical), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2009a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.3.0.0

Minor bug fix.

1.2.0.0

I've taken Jos's helpful comments on board. Both functions are now verctorised and run much quicker, especially for larger matrices.

1.0.0.0