CMPSC200 LECTURES 5-6VERIFIED STUDY GUIDE
MATLAB white space - Answers - Ignored by MATLAB
Continuation (3 dots / ...) - Answers - Use ellipses to spread many elements or code
across multiple lines
Matrix combination - Answers - Matrices can be combined together into larger
matrices
A(:, 1) - Answers - Selects all rows in column 1 (':' selects everything along that
dimension)
A(:) - Answers - Converts matrix into a single column vector
Empty matrices - Answers - Can be created/used to delete elements or initialize
containers
end keyword - Answers - Used to extract or reference the last element in an
array/dimension
B = A(end, :) - Answers - Extracts the last row of matrix A
L = A(:, end) - Answers - Extracts the last column of matrix A
meshgrid(x, y) - Answers - Creates 2D grid arrays for plotting
zeros(m, n) - Answers - Creates an m x n matrix of zeros
ones(m, n) - Answers - Creates an m x n matrix of ones
diag(A) - Answers - Extracts the main diagonal of a matrix
fliplr(A) - Answers - Flips matrix horizontally (left to right)
flipud(A) - Answers - Flips matrix vertically (up to down)
magic(n) - Answers - Creates an n x n magic square matrix
Logic error - Answers - Calculates the wrong thing, but code still executes without
crashing
Plotting purpose - Answers - Helps to visualize data and find errors
plot(t, y) - Answers - Creates a 2D line plot (t on horizontal x-axis, y on vertical y-
axis)
xlabel('...') - Answers - Sets the x-axis label
MATLAB white space - Answers - Ignored by MATLAB
Continuation (3 dots / ...) - Answers - Use ellipses to spread many elements or code
across multiple lines
Matrix combination - Answers - Matrices can be combined together into larger
matrices
A(:, 1) - Answers - Selects all rows in column 1 (':' selects everything along that
dimension)
A(:) - Answers - Converts matrix into a single column vector
Empty matrices - Answers - Can be created/used to delete elements or initialize
containers
end keyword - Answers - Used to extract or reference the last element in an
array/dimension
B = A(end, :) - Answers - Extracts the last row of matrix A
L = A(:, end) - Answers - Extracts the last column of matrix A
meshgrid(x, y) - Answers - Creates 2D grid arrays for plotting
zeros(m, n) - Answers - Creates an m x n matrix of zeros
ones(m, n) - Answers - Creates an m x n matrix of ones
diag(A) - Answers - Extracts the main diagonal of a matrix
fliplr(A) - Answers - Flips matrix horizontally (left to right)
flipud(A) - Answers - Flips matrix vertically (up to down)
magic(n) - Answers - Creates an n x n magic square matrix
Logic error - Answers - Calculates the wrong thing, but code still executes without
crashing
Plotting purpose - Answers - Helps to visualize data and find errors
plot(t, y) - Answers - Creates a 2D line plot (t on horizontal x-axis, y on vertical y-
axis)
xlabel('...') - Answers - Sets the x-axis label