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, 22Create a variable called
rows and set it to 2Use the
reshape function to reshape temps into a matrix called tempMatrix with rows rows and 4 columnsDisplay 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