nlinfit gives no result

2 vues (au cours des 30 derniers jours)
Silke
Silke le 8 Nov 2017
Réponse apportée : Eric le 9 Nov 2017
Hello!
When trying to fit data with nlinfit, I get the following error message:
Warning: Rank deficient, rank = 0, tol = 0.000000e+00. > In nlinfit>LMfit (line 574) In nlinfit (line 276) In TRMC_GuiFit_v2_tmax_SD_nlfit>FITANDPLOT_Callback (line 491) In gui_mainfcn (line 95) In TRMC_GuiFit_v2_tmax_SD_nlfit (line 42) In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)TRMC_GuiFit_v2_tmax_SD_nlfit('FITANDPLOT_Callback',hObject,eventdata,guidata(hObject)) Warning: Some columns of the Jacobian are effectively zero at the solution, indicating that the model is insensitive to some of its parameters. That may be because those parameters are not present in the model, or otherwise do not affect the predicted values. It may also be due to numerical underflow in the model function, which can sometimes be avoided by choosing better initial parameter values, or by rescaling or recentering. Parameter estimates may be unreliable. > In nlinfit (line 373) In TRMC_GuiFit_v2_tmax_SD_nlfit>FITANDPLOT_Callback (line 491) In gui_mainfcn (line 95) In TRMC_GuiFit_v2_tmax_SD_nlfit (line 42) In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)TRMC_GuiFit_v2_tmax_SD_nlfit('FITANDPLOT_Callback',hObject,eventdata,guidata(hObject)) Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.999277e-56. > In nlparci (line 104) In TRMC_GuiFit_v2_tmax_SD_nlfit>FITANDPLOT_Callback (line 492) In gui_mainfcn (line 95) In TRMC_GuiFit_v2_tmax_SD_nlfit (line 42) In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)TRMC_GuiFit_v2_tmax_SD_nlfit('FITANDPLOT_Callback',hObject,eventdata,guidata(hObject)) Warning: Imaginary parts of complex X and/or Y arguments ignored > In TRMC_GuiFit_v2_tmax_SD_nlfit>FITANDPLOT_Callback (line 657) In gui_mainfcn (line 95) In TRMC_GuiFit_v2_tmax_SD_nlfit (line 42) In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)TRMC_GuiFit_v2_tmax_SD_nlfit('FITANDPLOT_Callback',hObject,eventdata,guidata(hObject)) >>
Posting the code is a bit tricky, but I will do my best.
[xfit,resnorm, Jacob, CovB, MSE] = nlinfit( handles.timecorrcrop,handles.datacorrcrop',@funexp2conv410, handles.x0 );
handles.timecorrcrop = -1e-7:250e-12:1e-6;
handles.a1_GUESS_VALUE = 0.6;
handles.G1_GUESS_VALUE = 2.5e-8;
handles.a2_GUESS_VALUE = 0.4;
handles.G2_GUESS_VALUE = 3.5e-7;
handles.ETAMU_0_GUESS_VALUE = 0.04;
handles.x0 = [ handles.a1_GUESS_VALUE; 1/handles.G1_GUESS_VALUE; handles.a2_GUESS_VALUE; 1/handles.G2_GUESS_VALUE; handles.ETAMU_0_GUESS_VALUE ];
With the function being:
function f = funexp2conv410( param, t )
RC = 18e-9; % Time constant of cavity cell
a1 = param(1); % Parameters for bi-exponential decay
D1 = param(2);
a2 = param(3);
D2 = param(4);
etamu1 = param(5); %starting value of conductivity in cm2/Vs
assignin('base', 'D1', D1);
assignin('base', 'D2', D2);
filename1 = 'pulse410.txt';
pathname1 = 'D:\PulseShapes\';
pulse410 = importfile1([pathname1, filename1]);
[P,I] = max(pulse410(:,1)); %find the coordinates of the maximum value of t
t_in = find(t==P);
t_x = t(1:t_in);
pulse410s=spline(pulse410(:,1), pulse410(:,2), t_x); % make the pulse and the experimental data have the same time scale
f1x = conv(a1 * exp(-t*D1) + a2 * exp(-t*D2), pulse410s./75.5856)
f1(1:4000) = etamu1*f1x(1:4000);
assignin('base','f1',f1);
f2x = conv(exp(-t/RC),f1);
f(1:4000) = f2x(1:4000)/72.501;
I am not sure what the problem is. Are there too many convolutions in the fit? Thanks for your help!
  5 commentaires
Eric
Eric le 9 Nov 2017
Is the problem solved? If so, I will re-post my comment as an answer.
Silke
Silke le 9 Nov 2017
Yes, the problem is solved. Your answer gave the right indication on where to find the problem, and partly solved it. Thank you!

Connectez-vous pour commenter.

Réponse acceptée

Eric
Eric le 9 Nov 2017
In your function funexp2conv410, your line
t_in = find(t==P);
runs the risk of being empty, thereby causing output f to always be zeros, which is likely why it is complaining. Consider replacing those lines with
t_x = t(t<=P);
or whatever makes sense for your situation to avoid problems. Not sure if that's the only issue.
EDIT: Not a direct solve, but led OP to the answer. See comments to question.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by