I have a matlab script and one of the variables is:
a = 'false' % my string
my goal is to convert such variable into a boolean variable:
a = false % my goal
is there a matlab function that allows me to convert the string into a boolean value?
a = string2boolean('false') % I would like to have something like this
If there are no functions that allow to do that what could be another possible solution?
You can write one yourself, it's rather simple
function [output]=string2boolean(string)
if strcmp(string,'false')
output = false;
else
output = true;
end
end
Additionally you can altogether skip the function and simply
a = strcmp(a,'true');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With