matlab xlsread
时间: 2023-09-08 10:10:20 浏览: 36
The MATLAB function `xlsread` reads data from an Excel file. The basic syntax for `xlsread` is:
```
[num, txt, raw] = xlsread(filename, sheet, range)
```
where:
- `filename`: the name of the Excel file, including the file extension
- `sheet`: (optional) the name of the worksheet to read from
- `range`: (optional) the range of cells to read from the worksheet, specified as a string (e.g. `'A1:B10'`)
The output arguments are:
- `num`: a numeric array containing the contents of the specified cells
- `txt`: a cell array containing any text in the specified cells
- `raw`: a cell array containing the raw data in the specified cells (including any formatting)
By default, `xlsread` reads all data in the specified range. If the range includes cells that contain a mix of numeric and non-numeric data, `xlsread` will return an error. To read only the numeric data in a range that contains both numeric and non-numeric data, you can use the `'basic'` option:
```
[num] = xlsread(filename, sheet, range, 'basic')
```
This will return only the numeric data in the range, and ignore any non-numeric data.
Note that `xlsread` requires the Excel file to be in a supported format (e.g. .xls or .xlsx), and may require the installation of additional software (e.g. the Microsoft Excel software or the Microsoft Office Excel Driver).