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

Mar 7, 2025

MATLAB and Excel: Modifying Worksheets

Overview

In this session, we learn how to use MATLAB to delete rows or columns in an Excel worksheet and modify the contents of individual cells.

Key Steps and Concepts

Reading Data

  • Data Source: Resistor sheet from the components example.

Deleting a Column

  • Target: Fourth column containing 10k resistor information.
  • Action: Replace the column with an empty matrix.
    • Result: Column is removed and subsequent columns shift left.

Modifying Cell Content

  1. Changing Power Rating

    • Target: Power rating of the 220-ohm resistor.
    • Location: Third row, second column.
    • Action: Replace 0.5 watt with 1 watt.
    • Note: Use curly braces for cell array compatibility.
  2. Changing Resistor Value

    • Initial Change
      • Target: 5.1k resistor value.
      • Location: Second row, third column.
      • Action: Change 5.1k to 7.5k by replacing with '7k5'.
      • Note: Use curly braces for character array compatibility.
    • Alternative Method
      • Procedure: Change back to 5k1 and replace using direct content replacement.
      • Difference: Index with curly braces to replace content without creating a nested cell array.

Writing Data Back to Excel

  • Problem: Data has fewer columns after deletion.
  • Solution: Use Write Mode 'OverwriteSheet' to ensure the entire sheet is first erased.
    • Outcome: New data is written correctly, and unwanted columns are removed.

Next Steps

  • Upcoming Topic: Acquiring information from an Excel spreadsheet, performing computations, and updating the workbook with results.

This concludes the current session on modifying Excel worksheets using MATLAB. The techniques discussed allow for effective management and updating of spreadsheet data from within MATLAB.