0
我已经为我的程序改编了一些现有的代码,但是我遇到了一个我不知道原因的错误。我有N个观测数据,其中我的目标是将数据分解为越来越小的子样本,并对每个子样本进行计算。为了确定子采样大小将如何改变,程序找到N的除数并将其存储到数组OptN中。矩阵维必须在matlab中同意错误?
dmin = 2;
% Find OptN such that it has the largest number of
% divisors among all natural numbers in the interval [0.99*N,N]
N = length(x);
N0 = floor(0.99*N);
dv = zeros(N-N0+1,1);
for i = N0:N,
dv(i-N0+1) = length(divisors(i,dmin));
end
OptN = N0 + find(max(dv)==dv) - 1;
% Use the first OptN values of x for further analysis
x = x(1:OptN);
% Find the divisors >= dmin for OptN
d = divisors(OptN,dmin);
function d = divisors(n,n0)
% Find all divisors of the natural number N greater or equal to N0
i = n0:floor(n/2);
d = find((n./i)==floor(n./i))' + n0 - 1; % Problem line
在函数中,除数是发生问题的地方。我有'错误使用./矩阵尺寸必须同意'。但是,这与长度为60的输入数据一起工作,但是当我尝试长度为1058的数据时,它给了我上述错误。