You can use the xlsread
function in MATLAB to import your Excel sheet. Here's an example code snippet that demonstrates how to use it:
main.m261 chars13 lines
Explanation of parameters used in the xlsread function:
filename
is the name of your Excel file, including the extension.sheetname
is the name of the worksheet containing the data you want to import.range
specifies the rectangular range to be read from the worksheet, in the format 'A1:B2'.The function returns the numeric data in num
, the text data in txt
, and the raw data in raw
, which is a combination of numeric and text data. In this example, we only need the numeric data, so we assign num
to the variables we want to extract.
Note that xlsread
can be more flexible than the example above. You can omit the range
parameter to read the entire worksheet or use 'basic'
parameter to extract just numbers.
gistlibby LogSnag