23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Working with Spreadsheets<br />

Adding a New Worksheet. If the worksheet being written to does not<br />

already exist in the file, <strong>MATLAB</strong> displays the following warning:<br />

Warning: Added specified worksheet.<br />

You can disable these warnings with the command<br />

warning off <strong>MATLAB</strong>:xlswrite:AddSheet<br />

Importing from the File<br />

Use xlsread to import a matrix from an Excel spreadsheet file into the<br />

<strong>MATLAB</strong> workspace. You can import data from any worksheet in the file,<br />

and from any location within that worksheet. You can also optionally have<br />

xlsread open an Excel window showing the file and then interactively select<br />

the worksheet and range of data to be read by the function.<br />

Inputs to xlsread are<br />

• Name of the spreadsheet file<br />

• Matrix to be imported<br />

• Name of the worksheet from which to read the data<br />

• Range of cells on the worksheet from which to read the data<br />

• Keyword that opens an Excel window, enabling you to interactively select<br />

the worksheet and range of data to read<br />

• Keyword that imports using basic import mode<br />

Three separate outputs from xlsread are<br />

• Numeric data<br />

• String data<br />

• Any unprocessed cell content<br />

Example — Reading from an XLS File. Continuing with the previous<br />

example, to import only the numeric data, use xlsread with a single return<br />

argument. xlsread ignores any leading row or column of text in the numeric<br />

result:<br />

6-99

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!