Not enough input arguments + recursion issue

1 view (last 30 days)
Remy
Remy on 1 Apr 2014
Commented: Star Strider on 1 Apr 2014
Dear Matlab users,
I have this problem with my function. I want to make the fitting of a non linear model. and within my model I am using two recursive functions I1 and I2 and two regular functions Iph and Ish. My problem so for is that I have an message error telling me that I don't have enough inputs, and I don't really get why... I am not really familiar with recursive funcions, that might be the cause.
here's my code:
1)main code
% Temperature
X1=transpose(importdata('data_T1.mat'));
% Irradiance
X2=transpose(importdata('data_irradiance.mat'));
% Voltage DC
X3=transpose(importdata('data_V_dc.mat'));
% DC current
Y=transpose(importdata('data_I_dc.mat'));
% Creation du vecteur
X=[X1 X2 X3];
% Creation des parametres
% Resistance series 1 b1=beta(1);
% Resistance series 2 b2=beta(2);
% Dark saturation current 1 b3=beta(3);
% dark saturation current 2 b4=beta(4);
% Shunt resistance b5=beta(5);
% Series resistance b6=beta(6);
% Ideality factor 2 b7=beta(7);
% Current output
I=@(b,X) Iph(X(:,2),X(:,1))-I1(b(1),b(2),b(5),b(3),I2,Ish,X(:,3),X(:,1),b(6),Y,Iph)-I2(b(1),b(2),b(5),b(4),I1,Ish,X(:,3),X(:,1),b(6),b(7),Y,Iph)-Ish(b(5),X(:,3));
beta0=[0.6 2.3 1E-12 1E-7 10000 0 2];
beta=fitnlm(X,Y,I,beta0);
2)function I2 (I1 is the same)
function [ i ] = I2( R1,R2,Rsh,J2,I1,Ish,V,T,Rs,n2,Itot,Iph)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
k=1.3806488E-23;
q=1.60217657E-19;
while Itot-(Iph-(I1+I2+Ish))>0.01
i=R2./(R2+R1+Rsh).*J2.*exp((q.*(V-R2.*I2-(I1+I2+Ish).*Rs)/(n2.*k.*T))-1);
end
end
For the record,the b(1,2,3...) are from the syntax of the curve fitting function fitnlm.
The returned error is:
Error using nlinfit (line 205)
Error evaluating model function
'@(b,X)Iph(X(:,2),X(:,1))-I1(b(1),b(2),b(5),b(3),I2,Ish,X(:,3),X(:,1),b(6),Y,Iph)-I2(b(1),b(2),b(5),b(4),I1,Ish,X(:,3),X(:,1),b(6),b(7),Y,Iph)-Ish(b(5),X(:,3))'.
Error in NonLinearModel/fitter (line 1122)
[model.Coefs,~,J_r,model.CoefficientCovariance,model.MSE,model.ErrorModelInfo,~] = ...
Error in classreg.regr.FitObject/doFit (line 220)
model = fitter(model);
Error in NonLinearModel.fit (line 1430)
model = doFit(model);
Error in fitnlm (line 94)
model = NonLinearModel.fit(X,varargin{:});
Error in Parameters (line 58)
beta=fitnlm(X,Y,I,beta0);
Caused by:
Error using I2 (line 7)
Not enough input arguments.
Any help would be helpful. Thank you
  1 Comment
Star Strider
Star Strider on 1 Apr 2014
‘Ish’ and ‘Iph’ look like functions, but you don’t always refer to them as such. I see two situations in your I, I2 (and I assume I1 also) functions where you call them without arguments.
What are they?
NOTE: It is always a good idea to test-run and debug your objective functions (using your initial parameter estimates) before you use them in nlinfit or other routines. That way you know they work and will return values that match the data you intend to fit them to.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!