matlab中数据的导出和导入

大数据文件的导入和导出

函数名:matfile函数
函数描述:直接从mat文件中获取变量和改变变量,而无需加载mat文件中的变量。
例如:

% Open the example MAT-file, topography.mat.
filename = 'topography.mat';
m = matfile(filename);
topo = m.topo; %Read the variable topo from the MAT-file.
% Create a MAT-file object connected to the existing MAT-file named myFile.mat. 
% Enable write access to the MAT-file by setting Writable to true.
m = matfile('myFile.mat','Writable',true);
% Generate a 15-by-15 example array, y.
y = magic(15);
% Save y to the MAT-file. 
% Specify the variable in the MAT-file using dot notation similar to accessing fields of structure arrays.
m.y = y; % MATLAB adds a variable named y to the file.
% Display all variables stored in the MAT-file, myFile.mat.
whos('-file','myFile.mat')

% Determine the size of a variable, and then calculate the average of each column.
filename = 'stocks.mat';
m = matfile(filename);
[nrows,ncols] = size(m,'stocks');
avgs = zeros(1,ncols);
for i = 1:ncols
    avgs(i) = mean(m.stocks(:,i));
end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值