matlab中数据的导出和导入

来源:互联网 发布:英语朗读软件 编辑:程序博客网 时间:2024/05/18 00:42

大数据文件的导入和导出

函数名: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
1 0
原创粉丝点击