How to solve the Warning message "Warning: Iteration limit exceeded. Returning results from final iteration. ". How can I fix this problem?
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
"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 commentaires
Jan
le 18 Mai 2021
This piece of code is ugly and confusing:
y11=mat(1,:,i,j);y12=mat(2,:,i,j); y13=mat(3,:,i,j); y14=mat(4,:,i,j); y15=mat(5,:,i,j); y16=mat(6,:,i,j); y17=mat(7,:,i,j); y18=mat(8,:,i,j);
y21=mat(9,:,i,j);y22=mat(10,:,i,j);y23=mat(11,:,i,j);y24=mat(12,:,i,j);y25=mat(13,:,i,j);y26=mat(14,:,i,j);y27=mat(15,:,i,j);y28=mat(16,:,i,j);
Y = [y11,y12,y13,y14,y15,y16,y17,y18,y21,y22,y23,y24,y25,y26,y27,y28];
Nicer and faster:
Y = reshape(mat(1:16, :, i, j).', 1, []);
Réponse acceptée
Walter Roberson
le 18 Mai 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!