0
0
MATLABdata~5 mins

Reshaping arrays in MATLAB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the reshape function do in MATLAB?
The reshape function changes the size and shape of an array without changing its data. It rearranges elements into a new dimension.
Click to reveal answer
beginner
How do you reshape a 1x6 array into a 2x3 array in MATLAB?
Use reshape(array, 2, 3). This changes the array to have 2 rows and 3 columns.
Click to reveal answer
beginner
What must be true about the number of elements when reshaping an array?
The total number of elements must stay the same before and after reshaping. For example, a 6-element array can be reshaped to 2x3 or 3x2, but not 4x2.
Click to reveal answer
intermediate
What happens if you try to reshape an array to a size that doesn't match the number of elements?
MATLAB gives an error because the reshape function requires the total number of elements to remain constant.
Click to reveal answer
intermediate
How does MATLAB fill the reshaped array?
MATLAB fills the reshaped array column-wise, taking elements from the original array in column-major order.
Click to reveal answer
What does reshape(A, 3, 2) do if A is a 1x6 array?
AChanges A into a 2-row, 3-column array
BChanges A into a 3-row, 2-column array
CFlattens A into a 1x6 array
DThrows an error
What must be true for reshape to work without error?
AThe new shape must have the same total number of elements as the original
BThe new shape must have fewer elements
CThe new shape must have more elements
DThe new shape must be square
If you have a 2x3 matrix, which reshape is valid?
Areshape(A, 1, 5)
Breshape(A, 4, 2)
Creshape(A, 6, 2)
Dreshape(A, 3, 2)
How does MATLAB fill elements when reshaping?
ARow-wise
BIt reverses the order
CColumn-wise
DRandomly
What happens if you try reshape(A, 4, 2) on a 2x3 matrix?
AIt throws an error
BIt works fine
CIt truncates extra elements
DIt pads with zeros
Explain how the reshape function works in MATLAB and what rules must be followed.
Think about how you can rearrange a box of items without adding or losing any.
You got /4 concepts.
    Describe a real-life example that helps you understand reshaping arrays.
    Imagine moving books from one shelf layout to another.
    You got /4 concepts.