Matlab - variables Flashcards

1
Q

what is a string?

A

a string is text that is assigned to a variable

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

how would you write code to display first name and second name? how would you put them two together?

A

> > firstname = ‘Joe’ ;
surname = ‘Bloggs’ ;
fullname = [ firstname, ‘ ‘, surname]
note: here the ‘’ are for the space in between.

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

what is the num2str command?

A

The num2str function converts numbers to their string representations. This function is useful for labeling and titling plots with numeric values

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

how would you use num2str to produce ‘ Joe Bloggs is 25 years old’

A

age = 25;
agestring = [fullname, ‘ is ‘, num2str(age), ‘ years old’]

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

what are cells?

A

cells are like matrixes but with text instead of numbers. so just like a string but in a matrix format.

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

what kind of brackets do cells use?

A

{}

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

how would you reference individual items from a cell array?

A

using curly brackets, inside those brackets include the location of the item in the matrix. eg. stimuli{1,3}

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

what does the command strmatch do?

A

Find possible matches for character arrays or strings.

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

if
animals =
‘dog’ ‘cat’ ‘horse’ ‘rat’
what would strmatch(‘cat’,animals) return?

A

2

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