Strings Flashcards

1
Q

Converting string to number

A

Str2num(string)

X = double(string)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Converting numbers to string

A

Num2str(value)

X = char(value)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to compare strings correctly
How to compare strings while ignoring case

Comparing string using logical expression ==

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Difference between fprintf and sprintf

A

Fprintf prints stuff to the command line

Sprintf puts the stuff into an output argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Replacing characters or substrings in a string

A

Strrep(string_name,’char/substring to replace’,’char/string to replace with’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly