CS 1371 (Kantwon): Strings & Logical Indexing

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/16

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

17 Terms

1
New cards

A vector of characters.

String

2
New cards

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)

3
New cards

You can use the ___ operator to create strings with the ASCII table.

colon

4
New cards

Anytime you do math to a string, you get back a:

double (ASCII) value

5
New cards

When you do math to a string, you need to cast the result to:

char

6
New cards

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)

7
New cards

If the substring doesn't appear in the string in the strfind( ) function, it outputs:

an empty vector

8
New cards

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...)

9
New cards

This function allows you to replace part of a string with another string.

strrep(oldString, oldPart, newPart)

10
New cards

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)

11
New cards

Given a string & a substring, this function provides back a singular true if the substring is in the string. Case sensitive.

contains(str, substring)

12
New cards

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)

13
New cards

To compare characters in a case-insensitive way, you can use this function.

strcmpi(in1, in2)

14
New cards

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

15
New cards

If you know where the values in a vector are that you want to manipulate, should you use masking or regular indexing?

Regular indexing

16
New cards

Which logical operator has precedence: & or |?

&

17
New cards

How do you sum a mask?

sum(double(mask))