basic MATLAB operations Flashcards

1
Q

How would you wirte a first step last operation?

A

variable=[first:step:last]

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

Form a row vector

A

a=[2 3 5]

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

Form a column vector

A

b=[3;1;8]

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

Form a 2x2 matrix

A

c=[1 2;7 8]

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

Size of a vector a

A

size(a)

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

Size of row of vector a

A

size(a,1)

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

Size of column of vector a

A

siza(a,2)

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

absolute function

A

abs

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

natural logorithim

A

log

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

What does A(4,:) show

A

all elemnts in 4th row of matrix A

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

What does A([1 3],[2 4]) show

A

elements in rows 1&3, columns 2&4

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

How to plot a graph (2 steps)

A

1) define graph f(x)=
2) fplot(f, [-1:1]):

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

How would you write a linspace operation?

A

a=linspace(first,last,N)

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

create an array of all zeros

A

z=zeros(m,n)

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

create an array of all ones

A

o=ones(m,n)

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

create an array of random numbers

A

r=rand(m,n)

17
Q

How to clear window (keeps memory)

A

clc

18
Q

Write an identity matrix (ixi)

A

a=eye(i)

19
Q

How to see all variables

A

whos

20
Q

Overwriting arrays
Part of a matrix replaced by an identity matrix B

A

part needing replacing = new part
A(3:5,2:4)=B

21
Q

What are semicolons used for?

A

Supresses working out, code is still run but output stored in workplace

22
Q

for ones,zeros,rands and eye all ixi matrices can be represented similiary, how?

A

A=” “(i)

23
Q

Sidenote!!!!!

A

remember to name variables!!!!!!!!!!!!!!!

24
Q

Sidenote 2!!!!

A

arrays need square brackets!!!!!

25
Q

Sidenote 3!!!!!!!

A

rand,zeros,ones need normal brackets!!!!!

26
Q
A