请问matlab如何从excel表格中读取数据,谢谢
数据在excel表格的sheet1里面,第一列是人名(有些有空格),第二列和第三列是数字(浮点数),只有三列,第一行是一些说明,不是数据,要从第二行开始读数据请问怎么写,...
数据在excel表格的sheet 1 里面,第一列是人名(有些有空格),第二列和第三列是数字(浮点数),只有三列,第一行是一些说明,不是数据,要从第二行开始读数据
请问怎么写,才能把excel里面的数据读出来,存在三个列向量里,一个是人名,另外两个存第二列和第三列的数据,谢谢,在线等 展开
请问怎么写,才能把excel里面的数据读出来,存在三个列向量里,一个是人名,另外两个存第二列和第三列的数据,谢谢,在线等 展开
2个回答
展开全部
第一种方法,你可以使用xlsread函数来读取excel中的数据
第二种方法,就是把字符转化为数字,使用函数str2num
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. Click OK in the Data
Selection Dialog when you have finished selecting the active region.
祝你学习愉快!
第二种方法,就是把字符转化为数字,使用函数str2num
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. Click OK in the Data
Selection Dialog when you have finished selecting the active region.
祝你学习愉快!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询