求助大神,我做的MATLAB读取文件夹中数据的函数,文件数少正常,文件数多了就全部都是0.求解决办法。

function [ theta ] = get_matrix( )

%Get the Data from the Folder of Which the Path is

% the same as the Parameter str2

theta=zeros(100,1);

str1='centerline_';

str2='/Users/adobe/Desktop/backbone/group1/';

str3='.mat';

for i=260:300

k=num2str(i);

str=[str2,str1,k,str3];

load(str);

A=get_theta(centerline);

theta=[theta,A];

end

end

第1个回答  2016-08-22
你把所有的数据都读取存入theta,如果数据量较少,那不会有问题。

但是当数据量很大时,由于theta存在内存里,通常电脑4G,8G为主,况且matlab自身也有内存限制。

建议分批读取,处理。