Matlab basics I Flashcards

1
Q

;

A

suppresses output of command

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

num2str

A

converts numbers to a string

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

disp

A

displays array without printing array name; can also display text

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

figure (x)

A

causes x to be new figure

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

whos

A

generates list of variables and arrays in current workspace

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

diary

A

diary filename: saves all typed commands into “filename”
diary off: suspends input into diary file
diary on: resumes input into diary file

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

size ( )

A

displays dimension of the array

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

x(1,:)

A

first row of x

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

x(:,1)

A

first column of x

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

plot

A

plot: automatically opens figure window

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

figure

A

manually opens figure window

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

plot(x)

A

vectors: plots x vs. its index
matrices: plots columns of x vs their indices

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

plot (x,y)

A

vectors: plots vector y vs. vector x
matrices: plots rows/columns y vs rows/columns x (whichever line up); generates multiple curves

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

plot(x1, y1, x2, y2)

A

plots two curves: y1 vs x1 and y2 vs x2

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

plot(x1,y1, ‘r-‘, x2, y2, ‘b–’)

A

plots y1 vs x1 with a red solid line

plots y2 vs x2 with a blue dashed line

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

title(‘string’)

A

adds a title to a figure

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

xlabel(‘string’)

ylabel(‘string’)

A

adds label to x axis

adds label to y axis

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

semilogx(x,y)

A

plots y vs x using log scale for x and linear scale for y

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

semilogy(x,y)

A

plots y vs x using linear scale for x and log scale for y

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

loglog(x,y)

A

plots y vs x using log scale for both axes

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

bar(x)

A

vector: generates a vertical bar graph of the vector x vs its element index
matrix: groups data by row and generates a group of vertical bars

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

pie (x)

A

generates a pie chart with every element in x represented by a slice of the pie

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

hist(x)

A

generates a histogram. computes and plots number of values of x falling into 10 bins (default) equally spaced between min and max values

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

.fig

A

matlab figure file, can only be opened in matlab

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
print
exports figure plots as graphic images - deps: create encapsulated postscript image - djpeg: create a JPEG image - dtiff: creates a compressed TIFF image - dpng: create a portable network graphic color image
26
single( )
specifies single precision floating point numbers
27
realmax('single') | realmin('single')
the range of a positive real number of single-precision in MATLAB: 3.4028e+038 and 1.1755e-038
28
int8, int16, int32, int64
signed integers of 8, 16, 32, 64 bits
29
uint8, uint16, uint32, uint64
unsigned integers of 8, 16, 32, 64 bits
30
.*
array multiplication: denotes element-by-element multiplication arrays must have same dimensions unless one is scalar
31
./
array division: element-by-element division | arrays must have same dimensions unless one is scalar
32
char( )
specifies data type as character
33
single quote | ' '
identifies a character string; each letter/space is treated as an element in an array
34
logical ( )
converts an array of real numeric values into a logical array; non-zero real numbers are true (1) and zero is false (0)
35
input
displays a prompt string and waits for user to type in an input
36
input('****' , 's')
stores input as a string if 's' is the second argument
37
command window
where commands are entered
38
figure window
displays plots and graphs
39
edit window
where you create and modify programs/scripts | also serves as debugger
40
variable
a name representing a chosen value; can assign to be any form of data stored in matlab
41
constant
special kind of variable whose value can't be changed
42
expression
a combination of operations that produces another value arithmetic expressions produce an answer relational expressions produce true (1) or false (0)
43
assignment
variable is assigned a value
44
array
collection of data values in rows and columns
45
m-files
sequences of commands stored in files | "scripts" or "programs"
46
colour coding in edit window
``` comments: green variables and numbers: black complete character strings: pink incomplete character strings: red matlab keywords: blue ```
47
Matlab search path when a name is entered in the command window
1. looks for the name as a variable; displays value 2. looks for name as m-file in current directory; executes the function 3. looks for name as m-file in any directory; executes it
48
workspace
collection of all variables and arrays that can be used by MATLAB when a particular command, M-file, or function is executed.
49
clc
clears command window
50
clear
clears workspace variables
51
clf
clears figure window
52
scalar
1x1 array
53
vector
one dimensional array
54
matrix
two dimensional array
55
variable name restrictions
can only use letters, digits, and underscore. First character of name must be a letter case sensitive can't use name of predefined constants
56
plotting line type options
- solid : dotted -. dash-dot --dashed
57
plotting point type options
``` . point o circle x x-mark + plus * star s square d diamond v triangle down ^ triangle up < triangle left > triangle right p pentagram h hexagram ```
58
plotting colour type options
``` b blue g green r red c cyan m magenta y yellow k black ```
59
types of data stored in matlab
character logical numeric >integer: multiple signed integer types, multiple unsigned integer types >floating point: single precision and double precision, can store complex and real numbers as either single or double
60
bit
binary digit, either 1 or 0
61
byte
8 bits (8 binary digits that are each either 1 or 0)
62
double( )
specifies double precision floating point data; default type for matlab
63
realmax | realmin
give max and min values of a positive double precision floating point number 1.7977e+308 and 2.2251e-308
64
ASCII
American Standard Code for Information Interchange | seven bit code containing 128 numbers (0-127) each assigned to a character
65
character array
used to store character info in matlab | when creating a vector that contains both character and numeric values, matlab converts all data to character
66
logical array
contains values of 1 or 0 to denote true or false