Reputation: 59
I have a char vector which looks like this:
char_vec = '001100';
And I want to make it just a double vector:
double_vec = [0, 0, 1, 1, 0, 0];
I gave an example with only 6 values, but actually I have a very long char vector (approx. 2000 values). So the splitting should work on any vector length.
Can you help me please with this problem?
Upvotes: 0
Views: 32
Reputation: 4402
Use double
and subtract the ascii value of character '0'
char_vec = '001100';
double_vec = double(char_vec-'0')
double_vec =
0 0 1 1 0 0
Upvotes: 1