Reputation: 4771
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.
Upvotes: 0
Views: 1458
Reputation: 121127
Here's a variation that converts each character to a number.
function y = convert(s)
y = find(str2num(s')')
Upvotes: 2