using lsqnonlin function returns not a vector
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to find 10 parameters value using lsqnonlin. My function returns a 10*10 matrix. each column is the set of data that has to be summed and squared and give one parameter value.Is it possible to do it with lsqnonlin? my function is as follows:
function r = calcResiduals(parVector, settingsStruct)
for i = 1 : size(settingsStruct.expConditions,1) % loop through all experiments
conc = getconc(settingsStruct.expConditions(i,:),parVector);
for j=1:10
r1 = conc(:,j)-settingsStruct.measurementData(:,i);
r(:,j)=r1;
end
end
end
i am calling lsqnonlin as follows:
settingStruct.expConditions=[5 5 50];
settingStruct.measurementData=[5;4;3;2;1;0;0.9;0.8;0.7;0.6];
parVector=[1 1 1 1 1 1 1 1 1 1];
lsqnonlin(@calcResiduals,parVector,[],[],[],settingStruct)
|* _i am gtting error as follows :_ *|
Warning: Failure at t=2.879119e+000. Unable to meet integration tolerances without
reducing the step size below the smallest value allowed (7.105427e-015) at time t.
> In ode45 at 309
In getconc at 21
In calcResiduals at 5
In snls at 333
In lsqncommon at 175
In lsqnonlin at 237
In ModelDiscrimination at 68
Error using horzcat
CAT arguments dimensions are not consistent.
Error in getconc (line 27)
conc=[cout1(:,1) cout2(:,1) cout3(:,1) cout4(:,1) cout5(:,1) cout6(:,1) cout7(:,1)
cout8(:,1) cout9(:,1) cout10(:,1)];
Error in calcResiduals (line 5)
conc = getconc(settingsStruct.expConditions(i,:),parVector);
Error in snls (line 333)
newfvec = feval(funfcn{3},xcurr,varargin{:});
Error in lsqncommon (line 175)
[xC,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT,msgData]=...
Error in lsqnonlin (line 237)
[xCurrent,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
0 comentarios
Respuestas (1)
Matt J
el 19 de Oct. de 2014
Editada: Matt J
el 19 de Oct. de 2014
lsqnonlin doesn't care what shape your residual array, r, has. It will always be internally columnized to r(:), see
As for the error, it is because the different column vectors cout?(:,i) are not all the same length in
conc=[cout1(:,1) cout2(:,1) cout3(:,1) cout4(:,1) cout5(:,1) cout6(:,1) cout7(:,1)
cout8(:,1) cout9(:,1) cout10(:,1)];
So, they cannot be concatenated.
4 comentarios
Matt J
el 18 de Abr. de 2015
@PATHAN,
Your question looks to be completely unrelated to this thread, so you should probably start your own. However, a common reason why the initial point is a local min is because of quantization operations like round(), fix(), floor() in your objective function. There are rules about the kind of objective functions you can have.
Ver también
Categorías
Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!