Matlab - variables Flashcards
what is a string?
a string is text that is assigned to a variable
how would you write code to display first name and second name? how would you put them two together?
> > firstname = ‘Joe’ ;
surname = ‘Bloggs’ ;
fullname = [ firstname, ‘ ‘, surname]
note: here the ‘’ are for the space in between.
what is the num2str command?
The num2str function converts numbers to their string representations. This function is useful for labeling and titling plots with numeric values
how would you use num2str to produce ‘ Joe Bloggs is 25 years old’
age = 25;
agestring = [fullname, ‘ is ‘, num2str(age), ‘ years old’]
what are cells?
cells are like matrixes but with text instead of numbers. so just like a string but in a matrix format.
what kind of brackets do cells use?
{}
how would you reference individual items from a cell array?
using curly brackets, inside those brackets include the location of the item in the matrix. eg. stimuli{1,3}
what does the command strmatch do?
Find possible matches for character arrays or strings.
if
animals =
‘dog’ ‘cat’ ‘horse’ ‘rat’
what would strmatch(‘cat’,animals) return?
2