1/16
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
A vector of characters.
String
If you want to create a string that has an apostrophe in it, you need to:
type 2 apostrophes in a row (escaping a character)
You can use the ___ operator to create strings with the ASCII table.
colon
Anytime you do math to a string, you get back a:
double (ASCII) value
When you do math to a string, you need to cast the result to:
char
This function takes in a string & a pattern of characters we often call a "substring" (just a part of the overall string). It then produces a vector of the starting indices of where that substring is in the entire string.
strfind(str, substring)
If the substring doesn't appear in the string in the strfind( ) function, it outputs:
an empty vector
With this function you can use %s (strings), %d (doubles), and %f (doubles with controlled decimal points) to create spots to fill in later.
sprintf(str, var1, var2...)
This function allows you to replace part of a string with another string.
strrep(oldString, oldPart, newPart)
This function has 2 inputs: the 1st is the string you want to split, and the 2nd is the character(s) that you want to split it by (delimiters). If you don't include a second input, it assumes "space" is your delimiter.
strtok(str, split)
Given a string & a substring, this function provides back a singular true if the substring is in the string. Case sensitive.
contains(str, substring)
To compare characters, you can use this function, which takes in 2 chars & outputs a single true or false based on if they're the same.
strcmp(in1, in2)
To compare characters in a case-insensitive way, you can use this function.
strcmpi(in1, in2)
In this process, given a vector of logicals, true values indicate that indexing will occur, and false values indicate that indexing will not occur.
Masking
If you know where the values in a vector are that you want to manipulate, should you use masking or regular indexing?
Regular indexing
Which logical operator has precedence: & or |?
&
How do you sum a mask?
sum(double(mask))