将“布尔值”转换为“布尔值” MATLAB 中的字符串到数组
我需要将布尔索引字符串转换为一个数组,如下所示:
convert('11001') = [1 2 5]
convert('0000') = []
convert('001') = [3]
我不控制生成字符串的函数。
有什么想法可以以优雅的方式做到这一点吗?我已经用循环完成了它,但不知何故它看起来不对。
I need to convert a string of boolean indices into an array which would look like this:
convert('11001') = [1 2 5]
convert('0000') = []
convert('001') = [3]
I don't control the function which produces the string.
Any ideas to do this in an elegant way? I already did it whith a loop but it looks wrong somehow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是将每个字符转换为数字的变体。
Here's a variation that converts each character to a number.