MATLAB: Does an “if does not contain operator” exist

function

I am trying to write a function where the input must be entered in radians. My idea was to make the function return if the input does not contain "pi". Is there a way to do this?
ex. if you wanted to enter 90 you have to enter pi/2
Thanks

Best Answer

  • Trust the users of your program:
    d = input('Input angle in radians [0 <= x <= 2*pi]: ')
    Then even "pi/2" is a valid answer.
    Testing the input to contain the string 'pi' would be not sufficient: E.g. the string '32 pineappletrees' should not be accepted, but '3.14159265358979 / 2' should.