Vector Conditional Execution and String Operations Recall from the boolean expressions lecture that relational operators work on vectors. When used with conditional execution (if, while, etc), the resulting vector of booleans must be all 1's to be true. Quick example with vectors. Consider if choice == 'yes' String is a vector of characters Relational operators work element-wise comparing ACII values What if choice is no - error matrix dimensions must agree What if choice is Yes - equivalent to if [0 1 1] Can handle the first problem using short-curcuiting: if length(choice) == 3 && (choice == 'yes') Issue: only works with scalars, need some helper functions which change vectors of booleans into a single boolean any(vec) - true if any values in vec are true all(vec) - true if all values in vec are true Better way to do it: Use MATLAB string compare: strcmp(string1, string2) Compares 2 strings and returns 1 if they are equal, 0 otherwise strcmpi(string1,string2) Compares 2 strings ignoring case differences Other useful string functions: lower(str) - change str to lower case upper(str) - change str to upper case