📊

Module 6 Video - readmatrix: Acquiring Numeric Data from Excel: Part 4

Mar 7, 2025

Specifying Subsets of Data in Excel Using ReadMatrix

Introduction

  • Objective: Learn how to specify a subset of data within an Excel worksheet to import using ReadMatrix.
  • Reasons for Importing Subsets:
    • Avoid importing non-numeric data as NaN.
    • Only a subset of data may be needed to achieve processing goals.

Specifying Data Subsets

Use of Name-Value Pairs

  • Name used: range
  • Value: Can take several forms to define a rectangular block of data.

Methods to Specify Rectangular Blocks

  1. Opposite Corners:
    • Specify two opposite corners of the block.
    • Can be either of the two pairs and specified in any order (4 combinations).
  2. Top Left Corner:
    • Specify the top left corner.
    • ReadMatrix determines the bottom-most row and right-most column with data.

Additional Methods

  • Subset of Columns:
    • Specify columns to read.
    • Ignores leading blank rows and headers that are non-numeric.
  • Subset of Rows:
    • Specify rows to import.
    • Ignores leading blank columns but imports leading text columns as NaN.

Examples

Example 1: Reading Last Three Columns

  • Method 1: Specify top left corner, e.g., C1
    • Result: Imports the last three columns.
  • Method 2: Specify opposing corners, e.g., E1:C4
    • Result: Same as above.
  • Method 3: Specify columns, e.g., C:E
    • Result: Same as above.

Example 2: Reading Interior Values

  • Method: Specify opposing corners, e.g., B2:D3
    • Note: Cannot specify just columns or the upper left corner due to additional row/column inclusion.

Example 3: Avoiding Non-Numeric Headers

  • Worksheet: Demo6
  • Avoid importing column A as NaN:
    • Method 1: Specify opposite corners, e.g., B3:F6
    • Method 2: Specify only upper left corner, e.g., B3
    • Method 3: Specify columns, e.g., B:F

Conclusion

  • ReadMatrix Behavior: Will not ignore non-numeric columns to the left.
  • Future Videos: Continue investigation into subset data reading from Excel.

Notes

  • Ensure proper specification of worksheet and range for accurate data import.
  • MATLAB documentation is a useful resource for additional options not covered here.