Why is "fitoptions" returning the error "Too many input arguments"?
8 次查看(过去 30 天)
显示 更早的评论
I have defined the function 'BTKcon' and saved it in an .m file as seen below.
function [con] = BTKcon(Gamma,Delta,Z,T,V)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
u0Sq=@(Gamma,Delta,En)(1/2)*(1+(sqrt(((abs(En)+1i*Gamma).^2)-(Delta.^2))./(abs(En)+1i*Gamma)));
v0Sq=@(Gamma,Delta,En)(1/2)*(1-(sqrt(((abs(En)+1i*Gamma).^2)-(Delta.^2))./(abs(En)+1i*Gamma)));
alpha=@(Gamma,Delta,En)real(u0Sq(Gamma,Delta,En));
etta=@(Gamma,Delta,En)imag(u0Sq(Gamma,Delta,En));
betta=@(Gamma,Delta,En)real(v0Sq(Gamma,Delta,En));
gammaSq=@(Gamma,Delta,Z,En)((alpha(Gamma,Delta,En)+(Z.^2).*(alpha(Gamma,Delta,En)...
-betta(Gamma,Delta,En))).^2)+((etta(Gamma,Delta,En).*(2.*(Z.^2)+1))).^2;
BTKA=@(Gamma,Delta,Z,En)sqrt(((alpha(Gamma,Delta,En).^2)+(etta(Gamma,Delta,En).^2)).*((betta(Gamma,Delta,En).^2)...
+(etta(Gamma,Delta,En).^2)))./gammaSq(Gamma,Delta,Z,En);
BTKB=@(Gamma,Delta,Z,En)((Z.^2).*((((alpha(Gamma,Delta,En)-betta(Gamma,Delta,En)).*Z-2.*etta(Gamma,Delta,En)).^2)...
+((2.*Z.*etta(Gamma,Delta,En)+(alpha(Gamma,Delta,En)-betta(Gamma,Delta,En))).^2)))./gammaSq(Gamma,Delta,Z,En);
dFermi=@(E,V,T)11600.928.*exp(11600.928.*(E-V)./T)./(((1+exp(11600.928.*(E-V)./T)).^2).*T);
con = (1+Z.^2).*integral(@(E) real(dFermi(E,V,T).*(1+BTKA(Gamma,Delta,Z,E)-BTKB(Gamma,Delta,Z,E))),...
-0.015,0.015,ArrayValued=true);
end
I am able to define a 'fittype' using the above function.
ft = fittype('BTKcon( Gamma, Delta, Z, T, V)','independent',{'V'},'coefficients',{'Gamma','Delta','Z','T'})
However, when I try to use 'fitoptions' to define starting points or bounds on my coefficients (e.g., using the command below), I keep getting the error "Too many input arguments".
options = fitoptions(ft, 'Lower', [0.00001 0.0001 0 0.02])
Can someone help me see what I am doing wrong?
0 个评论
采纳的回答
Torsten
2022-10-31
fitoptions is part of fittype, not vice versa as you try to do. Thus fitoptions must be define before fittype:
options = fitoptions('Lower', [0.00001 0.0001 0 0.02]);
ft = fittype('BTKcon( Gamma, Delta, Z, T, V)','independent',{'V'},'coefficients',{'Gamma','Delta','Z','T'},options);
See the example under
Chapter Create Fit Options and Fit Type Before Fitting
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!