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
Q

print

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

single( )

A

specifies single precision floating point numbers

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

realmax(‘single’)

realmin(‘single’)

A

the range of a positive real number of single-precision in MATLAB:

3.4028e+038 and 1.1755e-038

28
Q

int8, int16, int32, int64

A

signed integers of 8, 16, 32, 64 bits

29
Q

uint8, uint16, uint32, uint64

A

unsigned integers of 8, 16, 32, 64 bits

30
Q

.*

A

array multiplication: denotes element-by-element multiplication
arrays must have same dimensions unless one is scalar

31
Q

./

A

array division: element-by-element division

arrays must have same dimensions unless one is scalar

32
Q

char( )

A

specifies data type as character

33
Q

single quote

‘ ‘

A

identifies a character string; each letter/space is treated as an element in an array

34
Q

logical ( )

A

converts an array of real numeric values into a logical array; non-zero real numbers are true (1) and zero is false (0)

35
Q

input

A

displays a prompt string and waits for user to type in an input

36
Q

input(‘**’ , ‘s’)

A

stores input as a string if ‘s’ is the second argument

37
Q

command window

A

where commands are entered

38
Q

figure window

A

displays plots and graphs

39
Q

edit window

A

where you create and modify programs/scripts

also serves as debugger

40
Q

variable

A

a name representing a chosen value; can assign to be any form of data stored in matlab

41
Q

constant

A

special kind of variable whose value can’t be changed

42
Q

expression

A

a combination of operations that produces another value
arithmetic expressions produce an answer
relational expressions produce true (1) or false (0)

43
Q

assignment

A

variable is assigned a value

44
Q

array

A

collection of data values in rows and columns

45
Q

m-files

A

sequences of commands stored in files

“scripts” or “programs”

46
Q

colour coding in edit window

A
comments: green
variables and numbers: black
complete character strings: pink
incomplete character strings: red
matlab keywords: blue
47
Q

Matlab search path when a name is entered in the command window

A
  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
Q

workspace

A

collection of all variables and arrays that can be used by MATLAB when a particular command, M-file, or function is executed.

49
Q

clc

A

clears command window

50
Q

clear

A

clears workspace variables

51
Q

clf

A

clears figure window

52
Q

scalar

A

1x1 array

53
Q

vector

A

one dimensional array

54
Q

matrix

A

two dimensional array

55
Q

variable name restrictions

A

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
Q

plotting line type options

A
  • solid
    : dotted
    -. dash-dot
    –dashed
57
Q

plotting point type options

A
. 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
Q

plotting colour type options

A
b blue
g green
r red
c cyan
m magenta
y yellow
k black
59
Q

types of data stored in matlab

A

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
Q

bit

A

binary digit, either 1 or 0

61
Q

byte

A

8 bits (8 binary digits that are each either 1 or 0)

62
Q

double( )

A

specifies double precision floating point data; default type for matlab

63
Q

realmax

realmin

A

give max and min values of a positive double precision floating point number
1.7977e+308 and 2.2251e-308

64
Q

ASCII

A

American Standard Code for Information Interchange

seven bit code containing 128 numbers (0-127) each assigned to a character

65
Q

character array

A

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
Q

logical array

A

contains values of 1 or 0 to denote true or false