Module 6 Video - writecell: Writing a Cell Array to a file: Part 2

Mar 7, 2025

Lecture Notes: WriteCell in MATLAB

Overview

  • Continuation of introduction to WriteCell from the previous video.
  • Focus on adding information about capacitors to a parts list in an Excel workbook using MATLAB.

Previous Video Recap

  • Creation of a new workbook.
  • Writing resistor information from cell arrays to the workbook.

Current Lecture

Writing Capacitor Information

  • Objective: Add capacitors to a separate sheet in the existing component list.xlss file.
  • Method: Demonstrating a different method to write information using MATLAB.

Cell Arrays and Syntax

  • Combine C-value, C-volt, and C-quant into a single three-row cell array.
  • Use of concatenation operator (square brackets) and curly braces.

Curly Braces vs. Parentheses

  • Mnemonic: Curly for contents.
  • Curly braces pull contents out of cell arrays, while parentheses retain the variable type.

Demonstration and Common Pitfalls

  • Without Outer Curly Braces:
    • Results in a single value when enclosed in command syntax.
    • Issue with semicolons indicating the end of a command rather than continuing to next row.
  • With Outer Curly Braces:
    • Contains all cell arrays but in a nested format which is unsupported by WriteCell for writing to spreadsheets.

Correct Approach

  • Original form for creating a 3x4 cell array:
    • Inner curly braces with colons extract contents.
    • Enclose in outer curly braces to form a complete cell array.

Writing to Spreadsheet

  • Successful write operation without errors.
  • New sheet labeled 'capacitors' with correct information.
  • Error encountered with nested cell arrays.

Conclusion

  • Successfully created and filled a 'capacitors' sheet in the Excel workbook.
  • Next video will cover reading information from spreadsheets, modification in MATLAB, and writing back to Excel.