matlab 3.1 Flashcards
subplot(m, n, p)
breaks figure window into m by n matrix, p is the graph number
histogram function
graphs histogram with input array and number of bins
histogram(x,5)
x array, 5 bins
symmetric error bar function
errorbar(x, y, e)
x and y vals, e as error. all inputs must be of same length
non symmetric error bars function
errorbar(x, y, d, u)
x and y vals, d as the yderr and u as xerr
how to adjust thickness of graph lines
plot(x, y, ‘LineWidth’, 2.0)
plot3 function
graphs in three dimensions and takes three inputs:
plot3(x, y, z)
meshgrid
takes 2 input vectors and creates two 2d matrices for x and y
Xmatrix is copy of x vector over and over, same for y but in columns
[X, Y] = meshgrid(x,y)
x and y are input veectors
X is the output matrix, Y is output matrix
how do you get Z with meshgrid?
Z = sin(X) .* cos(Y)
surf(x,y,z)
shows on three planes with contour lines
contour function
represents 3D surface using 2D contour
how can you create animations
with loops
linear interpolation
uses existing line to estimate value at certain point based off of known points
ex: interp1(x,y,new_x)
cubic spine interpolation
smooths curve, minimizes eror
ex: interp1(x,y, new_x, ‘spline’)
least squares fitting
finds best fit for data points based on slope and intersection