matlab中怎样将excle数据导入,具体的方法是怎样?
我用了函数xlsread还是不行错误提示“>>a=xlsread('ai.xls');???XLSREADunabletoopenfileai.xls.Errorusin...
我用了函数 xlsread 还是不行 错误提示“>> a=xlsread('ai.xls');
??? XLSREAD unable to open file ai.xls.
Error using ==> iofun\private\validpath
File D:\matlab\work\ai.xls not found.
” 而且我把文件已经复制到work文件夹下了的。求高手帮助。。。 展开
??? XLSREAD unable to open file ai.xls.
Error using ==> iofun\private\validpath
File D:\matlab\work\ai.xls not found.
” 而且我把文件已经复制到work文件夹下了的。求高手帮助。。。 展开
展开全部
用xslread
A = xlsread(xls文件,参数)
假如当前工作路径下面有一个文件名为data的excel文件,读取函数是xlsread
a=xlsread('data.xls');
当导入txt时用
[num,txt]=xlsread('data.txt')
num:保存数据
txt:保存字符。
用 help xlsread
可以查到它的使用方法:
EXAMPLES:
1. Default operation:
NUMERIC = xlsread(FILE);
[NUMERIC,TXT]=xlsread(FILE);
[NUMERIC,TXT,RAW]=xlsread(FILE);
2. Get data from the default region:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet')
3. Get data from the used area in a sheet other than the first sheet:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet','sheet2')
4. Get data from a named sheet:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet','NBData')
5. Get data from a specified region in a sheet other than the first
sheet:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet','sheet2','a2:j5')
6. Get data from a specified region in a named sheet:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet','NBData','a2:j5')
7. Get data from a region in a sheet specified by index:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet',2,'a2:j5')
8. Interactive region selection:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet',-1);
You have to select the active region and the active sheet in the
EXCEL window that will come into focus. Enter any letter at Matlab
command line when finish selecting the active region.
9. Using the custom function:
[NUMERIC,TXT,RAW,CUSTOMOUTPUT] = xlsread('equity.xls', ..., @MyCustomFun)
Where the CustomFun is defined as:
function [DataRange, customOutput] = MyCustomFun(DataRange)
DataRange.NumberFormat = 'Date';
customOutput = 'Anything I want';
或者下面例子的方法:
Example -- Importing Data From an Excel Application
Assume that you have an Excel spreadsheet stocks.xls. This spreadsheet contains the prices of three stocks in row 3 (columns 1 through 3) and the number of shares of these stocks in rows 6 through 8 (column 2). Initiate conversation with Excel with the command
channel = ddeinit('excel','stocks.xls')
DDE functions require the rxcy reference style for Excel worksheets. In Excel terminology the prices are in r3c1:r3c3 and the shares in r6c2:r8c2.
Request the prices from Excel:
prices = ddereq(channel,'r3c1:r3c3')
prices =
42.50 15.00 78.88
Next, request the number of shares of each stock:
shares = ddereq(channel, 'r6c2:r8c2')
shares =
100.00
500.00
300.00
A = xlsread(xls文件,参数)
假如当前工作路径下面有一个文件名为data的excel文件,读取函数是xlsread
a=xlsread('data.xls');
当导入txt时用
[num,txt]=xlsread('data.txt')
num:保存数据
txt:保存字符。
用 help xlsread
可以查到它的使用方法:
EXAMPLES:
1. Default operation:
NUMERIC = xlsread(FILE);
[NUMERIC,TXT]=xlsread(FILE);
[NUMERIC,TXT,RAW]=xlsread(FILE);
2. Get data from the default region:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet')
3. Get data from the used area in a sheet other than the first sheet:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet','sheet2')
4. Get data from a named sheet:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet','NBData')
5. Get data from a specified region in a sheet other than the first
sheet:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet','sheet2','a2:j5')
6. Get data from a specified region in a named sheet:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet','NBData','a2:j5')
7. Get data from a region in a sheet specified by index:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet',2,'a2:j5')
8. Interactive region selection:
NUMERIC = xlsread('c:\matlab\work\myspreadsheet',-1);
You have to select the active region and the active sheet in the
EXCEL window that will come into focus. Enter any letter at Matlab
command line when finish selecting the active region.
9. Using the custom function:
[NUMERIC,TXT,RAW,CUSTOMOUTPUT] = xlsread('equity.xls', ..., @MyCustomFun)
Where the CustomFun is defined as:
function [DataRange, customOutput] = MyCustomFun(DataRange)
DataRange.NumberFormat = 'Date';
customOutput = 'Anything I want';
或者下面例子的方法:
Example -- Importing Data From an Excel Application
Assume that you have an Excel spreadsheet stocks.xls. This spreadsheet contains the prices of three stocks in row 3 (columns 1 through 3) and the number of shares of these stocks in rows 6 through 8 (column 2). Initiate conversation with Excel with the command
channel = ddeinit('excel','stocks.xls')
DDE functions require the rxcy reference style for Excel worksheets. In Excel terminology the prices are in r3c1:r3c3 and the shares in r6c2:r8c2.
Request the prices from Excel:
prices = ddereq(channel,'r3c1:r3c3')
prices =
42.50 15.00 78.88
Next, request the number of shares of each stock:
shares = ddereq(channel, 'r6c2:r8c2')
shares =
100.00
500.00
300.00
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2010-09-09
展开全部
[num]=xlsread('exmp.xls','sheet1')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我用过下面的xlsread,但是 这样的话,xlsread文件里面必须是 纯数字的,要是有中文就错,不知道那位大人能给指导一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
直接File --> Import Data... 不就可以吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询