Module 6 Video - Modifying Excel Workbooks with MATLAB: Part 1

Mar 7, 2025

Using MATLAB to Modify an Excel Workbook

Overview

  • Continuing with the parts list example from previous videos.
  • Focus on modifying an Excel workbook (components.xlsx) using MATLAB.
  • Main task: Reading Excel data into a MATLAB variable and modifying it.

Reading Data

  • Data from the Excel sheet "resistor data" is read into a MATLAB variable rdata.
  • Initial observation: Layout is not user-friendly, requires context to understand.

Enhancing Data Readability

Adding Row Descriptions

  • Objective: Add a column with row descriptions.
  • Create a 3-element cell array rowhead for row labels:
    • 1st Row: Component values in ohms.
    • 2nd Row: Minimum power rating in watts.
    • 3rd Row: Number of each component required.
  • Ensure rowhead is a single column cell array using semicolons.

Concatenating Row Descriptions

  • Use concatenation operator (square brackets) to add rowhead to rdata.
  • Concatenation requirement: Consistent dimensions (same number of rows).
  • Result: rdata becomes a 3x6 matrix with labels added to the left.

Adding a Top Description

  • Objective: Add a general description at the top of the data.
  • Create a variable tophead with text "list of resistors for gizmo".
  • Concatenate tophead to rdata vertically, ensuring the same number of columns.
  • Use the size function to determine the column count of rdata.
  • Expand tophead to match column count by adding space characters.
  • Result: rdata becomes a 4x6 matrix with description at the top.

Writing Back to Excel

  • Write the modified rdata back to the Excel file.
  • Sheet specified as "resistors", though it's the first sheet.
  • Note: Excel formatting required for better appearance (e.g., merging cells, centering headers).

Next Steps

  • Plan to explore adding data into the middle of data matrices, not just at edges.