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的數據時,它給了我上述錯誤。