0
0
MATLABdata~30 mins

Reshaping arrays in MATLAB - Mini Project: Build & Apply

Choose your learning style9 modes available
Reshaping arrays
📖 Scenario: You are working with a small dataset of daily temperatures recorded in a week. The data is currently in a single row, but you want to organize it into a matrix that shows temperatures for each day in a more readable way.
🎯 Goal: You will reshape a 1D array of temperatures into a 2D matrix with 2 rows and 4 columns to better visualize the data.
📋 What You'll Learn
Create a 1D array called temps with the exact values: 22, 24, 19, 23, 25, 21, 20, 22
Create a variable called rows and set it to 2
Use the reshape function to reshape temps into a matrix called tempMatrix with rows rows and 4 columns
Display the tempMatrix using disp
💡 Why This Matters
🌍 Real World
Reshaping arrays is useful when you want to organize data differently for analysis or visualization, like turning a list of daily measurements into a table format.
💼 Career
Many jobs in data analysis, engineering, and science require reshaping data arrays to prepare data for calculations, graphs, or reports.
Progress0 / 4 steps
1
Create the temperature array
Create a 1D array called temps with these exact values: [22, 24, 19, 23, 25, 21, 20, 22]
MATLAB
Need a hint?

Use square brackets [] to create the array and separate values with commas.

2
Set the number of rows
Create a variable called rows and set it to 2
MATLAB
Need a hint?

Just assign the number 2 to the variable rows.

3
Reshape the array into a matrix
Use the reshape function to reshape temps into a matrix called tempMatrix with rows rows and 4 columns
MATLAB
Need a hint?

The reshape function takes the array, number of rows, and number of columns as arguments.

4
Display the reshaped matrix
Use disp to display the variable tempMatrix
MATLAB
Need a hint?

Use disp(tempMatrix) to show the matrix in the command window.