I am trying to use the find operator in Matlab as a boolean and Im wondering if its even possible, if so how so?
This is what I am trying to do
//If The second column in X contains a 1, do something
if(find(X(:,2) == 1) == true)
//do something
I think you're looking for the any function:
if(any(X(:,2) == 1))
//do something
You could achieve something like this using find, I wouldn't recommend it though. Here is one option:
if(numel(find(X(:,2) == 1)) > 0)
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