1、matlab读取文件中的数据

1)列数相同的纯数据:load

sample_file.txt

1 % Load the file to the matrix, M :
2 M = load('sample_file.txt') 

 2)有注释(无独立的数字串)、字段名、列数相同的数据:importdata

sample_file2.txt :

1 %read the fata from the file 'sample_file2.txt' and create a
2 %structure D that contains both data and text data
3 D = importdata('sample_file2.txt');
4 data = D.data;
5 text = D.textdata; 

2、matlab与excel的数据交换

1)matlab读取excel数据:xlsread

一般直接利用excel读取dat文件的数据更为简单

1 %format:xlsread(fileroute','sheet','range')
2 y=xlsread('sample.xlsx','sheet1','c2:c20')

2)matlab将数据保存在excel中:xlswrite

%format:xlswrite('filename.xls',variablename,'sheet','range')
b=[1,2,3,4,5,6];
xlswrite('test.xls',b','Sheet2','B');

 

 

 

 

posted on 2013-07-01 19:30  uumonkey  阅读(374)  评论(2编辑  收藏  举报