Why does the memory needed to run nlinfit increases with every iteration?
Show older comments
Hi,
I am using nlinfit to identify the decay constants and amplitudes of a physiological process through input-output pairs. I have noticed that for large sets, nlinfit fails due to a "Out of Memory" error. However, depending on the length of the set, I can make the nlinfit code run for a certain number of iterations before it runs out of memory...
My question is why does the memory usage of nlinfit increases with the number of iterations? Doesn't the function clear the variables it doesn't need?
My objective function looks like the following:
% This function takes the input to the system of a number of experiments and
% a guess at the model parameters and computes the model output by convolving
% the input with the model. The convolution is done through an fft
% convolution
% INPUT
% x: parameter values, size 1x(nExp*2)+2
% vtime (~): independent variable (time),
% Vin: cell array of size 1xnExp where each cell contains a 9002x1 vector
% representing the input to the system.
% newFs: sampling frequency
% nExp: number of trials in the data set
% OUTPUT
% f = concatenated vector of the model responses
function f = combfobjectiveV(x,~,Vin, newFs,nExp)
f=cell(nExp,1);
for i = 1:nExp
t = (0:length(Vin{i})-1)/newFs;
impulseR = @(x) ((1-x(i+2))/x(2))*(exp(-(t-abs(x(i+2+nExp)))/x(2)))+ ...
(x(i+2)/x(1))*(exp(-(t-abs(x(i+2+nExp)))/x(1)));
secondOrderFitV = convfft(Vin{i},impulseR(x))./newFs;
f{i} = secondOrderFitV(1:length(Vin{i}))';
end
f= [f{:}];
Answers (0)
Categories
Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!