matlab week 1.2 Flashcards

(31 cards)

1
Q

vectors

A

one dimensional collection of variables written between brackets []

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

[1 2 3 4 5 ]

A

row vector

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

[1; 2; 3; 4; 5]

A

column vector

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

size(x)

A

returns dimensions of row (two values, n by m)

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

length(x)

A

returns number of elements in a vector (one value)

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

linspace

A

generates row vector of n points between and including two points

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

y = linspace(a, b, n)
what does each letter represent?

A

y is the created row vector
a is the starting number, included
b is the end number, included (if it fits in increment)
n is the number of points generated

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

linspace(1,5)

A

returns 1 by 100 vector between 1 and 5

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

default ‘n’ if not specified by linspace function

A

100

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

linspace(1, 5, 1)

A

5
you generated one number between 1 and 5 so it took a stepsize of 5

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

t = [1 2 3]
y = log(t)
what is y?

A

y = [ log(1), log(2), log(3) ]

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

element wise operations

A

use dot
.* ./ .^

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

transpose

A

converts column vector into a row vector and vice versa (‘)

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

a = [ 1 2 3]
a’

A

a =
1
2
3

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

b = [ 1, 2, 3, 4 + i]
b’

A

b =
1
2
3
4 - i

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

b = [ 1 2 3 4+i]
b.’

17
Q

zeros and ones function

A

zeros -> creates n by m matrix filled with 0s
ones -> creates n by m matrix filled with 1s

18
Q

ones(3)

A

1 1 1
1 1 1
1 1 1

19
Q

zeros(2, 3)

20
Q

rand function

A

generates matrix with random numbers between 0 and 1

21
Q

rand(3)

A

random 0-1 matrix of 3 by 3 dims

22
Q

randi(10,1,5)

A

randomly generates 10 integer numbers (whole numbers) between 1 and 5

23
Q

writing mathmatical equations in matlab

A

use the roots function with value as coefficient and index as the root

24
Q

6e^-10t

A

6 * exp(-10 * t)

25
save FileName a b
saves variables a and b to the file FileName.mat
26
load FileName
loads variables in FileName.mat into the wordkspace
27
fid = fopen(filename, permission)
filename is the name of file permission: 'r' for open file for reading 'w' for open file for writing
28
uigetfile
standard open file dialog box
29
[newfile, newpath] = uigetfile('*.*', 'Select File')
used to save the data in .txt format and set path newfile is the name of the new file newpath is where the file is stored on your computer
30
cd(newpath)
changes the current directory
31
format specs fprint(fid, format, A...) format: % 6.3f % 6.3f /n
%_# -> space after percent means insert space before the value in file 6 is the field width, 6 numbers in total printed 3 is the precision, 3 points after decimal f means floating point number repeated to signify format spec for number of columns in matrix