Strings Flashcards
Converting string to number
Str2num(string)
X = double(string)
Converting numbers to string
Num2str(value)
X = char(value)
How to compare strings correctly
How to compare strings while ignoring case
Comparing string using logical expression ==
Strcmp(s1,s2)
Strcmpi(s1,s2)
Using == compares each character in the string and returns logical value for each character instead of the entire string
Difference between fprintf and sprintf
Fprintf prints stuff to the command line
Sprintf puts the stuff into an output argument
What is a substring
Function to find a substring / character in a string
What does the function return?
What happens if there are multiple same substrings / characters in the string
Substring = small section of string in an actual string
Strfind(string,substring/char)
Function returns the location of the first occurrence found
Returns the location of first occurrence per substring/character found
Replacing characters or substrings in a string
Strrep(string_name,’char/substring to replace’,’char/string to replace with’)