Matlab Flashcards

1
Q

• MATLAB variable and file name conventions

A

cant start with a number
cant be the name of a fucntion
cant exceed namelengthmax
or be a keyword

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

when to use ()

A

Use parentheses to specify precedence of operations, enclose function input arguments, and index into an array.

also indexing

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

when to use []

A

Array construction

Array concatenation

Empty matrix and array element deletion

Multiple output argument assignment

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

when to use {}

A

Cell array assignment and contents

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

Difference between script & function

A

scripts can be run on their own but functions need to be called

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

input

A

x = input(prompt)

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

output

A

fprintf(‘Happy Birthday\n’);
fprintf(‘My name is %s\n’, prof_name);

disp(X)

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

syntax

A

missing semicolon etc

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

global workspace

A

avalable to everything

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

local workspace

A

only avalable to the function that it is called in

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

• What is considered “good practice”?

A

formatting and commenting

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

2d plots

A

plot(X,Y)

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

indexing arrays

A

do it 2d like

matrix(Row,Collum)

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

matrix with integer referencing

A

matrix(num) num is the number of the array

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

Array resizing and reshaping

A

ASK

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

loading files matlab

A

load(filename)

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

Element-wise operators

A

.* .^ ./

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

Transposing arrays

A

array’

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

Clc

A

Clear command window

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

Close

A

Clear system memory

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

find

A

k = find(X) returns a vector containing the linear indices of each nonzero element in array X.

22
Q

ans

A

funcitons as the most recent answer

23
Q

• Iskeyword

A

Tests if iskeyword(word) is a

24
Q

• zeros

A

creates an array of zeroes (row,collum)

25
Q

ones

A

creates an array of ones (row,collum)

26
Q

rand

A

uniformly distributed random numbers

27
Q

randn

A

Normally distributed random numbers

28
Q

randi

A

Uniformly distributed pseudorandom integers

X = randi(imax) returns a pseudorandom scalar integer between 1 and imax.

29
Q

linspace

A

y = linspace(x1,x2) returns a row vector of 100 evenly spaced points between x1 and x2.

30
Q

logspace

A

y = logspace(a,b,n) generates n points between decades 10^a and 10^b.

31
Q

length

A

n = length(X) returns the size of the longest dimension of X. If X is a vector, this is the same as its length.

32
Q

size

A

d = size(X) returns the sizes of each dimension of array X in a vector d with ndims(X) elements.

33
Q

numel

A

n = numel(A) returns the the number of elements, n, in array A.

34
Q

sort

A

B = sort(A) sorts the elements of A in ascending order.

If A is a vector, then sort(A) sorts the vector elements.

If A is a matrix, then sort(A) treats the columns of A as vectors and sorts each column.

35
Q

A

transposes teh array

36
Q

end

A

terminates the block of code

37
Q

round

A

= round(X) rounds each element of X to the nearest integer. In the case of a tie,

38
Q

xor

A

C = xor(A,B) performs a logical exclusive-OR of arrays A and B and returns an array containing elements set to either logical 1 (true) or logical 0 (false)

39
Q

max

A

M = max(A) returns the maximum elements of an array.

40
Q

mean

A

M = mean(A) returns the mean of the elements of A

41
Q

median

A

M = median(A) returns the median value of A.

42
Q

std

A

S = std(A) returns the standard deviation of the elements of A along the first array

43
Q

sum

A

S = sum(A) returns the sum of the elements of A along the first array dimension whose size does not equal 1.

44
Q

exp

A

Y = exp(X) returns the exponential ex for each element in array X. For complex elements z = x + iy, it returns the complex exponential

45
Q

log

A

Y = log(X) returns the natural logarithm ln(x) of each element in array X.

46
Q

polyfit

A

p = polyfit(x,y,n) returns the coefficients for a polynomial p(x) of degree n that is a best fit (in a least-squares sense) for the data in y. The coefficients in p are in descending powers, and the length of p is n+1

47
Q

meshgrif

A

p = polyfit(x,y,n) returns the coefficients for a polynomial p(x) of degree n that is a best fit (in a least-squares sense) for the data in y. The coefficients in p are in descending powers, and the length of p is n+1

48
Q

loglog

A

loglog(Y) plots the columns of Y versus their index if Y contains real numbers. If Y contains complex numbers, loglog(Y) and loglog(real(Y),imag(Y)) are equivalent. loglog ignores the imaginary component in all other uses of this function.

49
Q

• Semilogx

A

semilogx plot data as logarithmic scales for the x-axis.

50
Q

T = readtable(filename) creates a table by reading column oriented data from a file.

readtable determines the file format from the file extension:

A

num = xlsread(filename) reads the first worksheet in the Microsoft® Excel® spreadsheet workbook named filename and returns the numeric data in a matrix.

51
Q

sound

A

sound(y) sends audio signal y to the speaker at the default sample rate of 8192 hertz.

example
sound(y,Fs) sends audio signal y to the speaker at sample rate Fs.

example
sound(y,Fs,nBits) uses nBits bits per sample for audio signal y.

52
Q

beep

A

beep produces your computer’s default beep sound, if it is enabled.