数模学习笔记(一)

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');

 

 

 

 

转载于:https://www.cnblogs.com/wl142857/p/3165382.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值