MATLAB Answers

How to solve the Warning message "Warning: Iteration limit exceeded. Returning results from final iteration. ". How can I fix this problem?

9 views (last 30 days)
SA
SA on 18 May 2021
Commented: SA on 19 May 2021
"Warning: Iteration limit exceeded. Returning results from final iteration. "
I've a 4D array 'terminal' of which
X=[x11,x12,x13,x14,x15,x16,x17,x18,x21,x22,x23,x24,x25,x26,x27,x28]; % contain 16*16 matrix
tic
% Data RECALL from Saving
rec = load('A_4th_spac_250files.mat');
terminal=rec.terminal;
[d1,d2,d3,d4]=size(terminal); % size of 4D array
mat=terminal;
coefficients=zeros(d3,d4);
% hw = waitbar(0,'Running...'); % Waitbar
% for qq = 1:d3
for i= 1:d3 %% Frequency
for j=1:d4 %% Cycle
Y = reshape(mat(1:16, :, i, j).', 1, []);
% Sorting the values
sorted = (sortrows([X',Y'], 1))';
x = sorted(1,:); y = sorted(2,:);
modelfun = @(k,x) besselj(0,k.*x);
k0 = 1; % Initial condition Bessel First
% Fit the model
mdl = fitnlm(x',y',modelfun,k0);
coefficients(i,j) = mdl.Coefficients{:, 'Estimate'}; % To find the Co-efficients for every frequency every 10s data stretch
xq = (0:0.01:20)'; yq = predict(mdl,xq);
end
end
for every d3 & d4 points, I want to find the Bessel coefficients of d1,d2. For this reason, I've used the matlab scripts attached herewith. For this warning, I got wrong results
Can anybody help me to fix the Matlab Warning ? Your support is appretiated. Thanks.
  2 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 18 May 2021
opt = statset('MaxFunEvals', 1e5, 'MaxIter', 1e5);
mdl = fitnlm(x',y',modelfun,k0, 'options', opt);
This is one of the few routines that needs the options passed in as a name/value pair instead of as a positional parameter.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!