CS 1371 Lecture Notes - Lecture 16: C String Handling
Document Summary
Vector and indexing and masking examples: indexing lower case letters out of a string. Ex: str = hello, how are you?" out = elloowreou". Solution: out = str(str>="a" & str<="b": indexing even / odd numbers. Ex: vec = [1 2 3 4 5 6 7 8] out = [2 4 6 8] Solution: out = vec(mod(vec,2)==0: index out all nonzero values. Ex: vec = [1 2 0 4 5 0 7 0] out = [1 2 4 5 7] Solution: out = vec(vec~=0: reverse a vector (without fliplr) Ex: vec = [1 2 3 4] out = [4 3 2 1] Ex: str = hello 123" out = true. Solution: number = str(str>="0" & str<="9") out = length(number)>0 (there are other ways to do this so feel free to go over more than 1 way: convert a string to camel case. Ex: str = how old are you" out = howoldareyou".