Issue with calling variables through multiple functions, not enough input arguments
5 ビュー (過去 30 日間)
古いコメントを表示
Hi all, I'm still farily inexperienced with matlab. I am trying to break up an equation into smaller parts (the 4 functions) to make it easier to check/modify when I integrate the Gammasigma function but I keep getting 'not enough input arguments,' and the error lists every function as part of the error. I know that I am doing something wrong with the variable calls but I am not sure what specifically my issue is or how to fix it.
syms Egam
ECrit = 5;sigmaT = 1; me = 510;
compton1 = vpaintegral(Gammasigma,Egam,15,30);
compton2 = vpaintegral(Gammasigma,Egam,11,30);
compton = compton1/compton2;
function Gs = Gammasigma(Egam,ECrit,sigmaT,me)
Gs = (exp(-exp(-((log(Egam)+1.2)./(.8)))-((log(Egam)+1.2)./(.8))+1)).*s3;
end
function sigma3 = s3(Egam,ECrit,sigmaT,me)
sigma3 = s2+(3.*sigmaT)./(8).*(1)./(((Egam)./(me)).^3).*(1-((Egam)./(me))-(1+2.*((Egam)./(me)))./(1+((Egam)./(me)) ...
.*(1-(1-(me)./(Egam).*((ECrit)./(Egam))./(1-(ECrit)./(Egam)))))-((Egam)./(me)).*(1-(me)./(Egam).*((ECrit)./(Egam))./(1-(ECrit)./(Egam))));
end
function sigma2 = s2(Egam,ECrit,sigmaT,me)
sigma2 = s1+(3.*sigmaT)./(8).*(1)./(2.*((Egam)./(me))).*((1)./(1+((Egam)./(me)).*(1-(1-(me)./(Egam).*((ECrit)./(Egam)) ...
./(1-(ECrit)./(Egam))))).^2-(1)./(1+2.*((Egam)./(me))).^2);
end
function sigma1 = s1(Egam,ECrit,sigmaT,me)
sigma1 = (3.*sigmaT)./(8).*((((Egam)./(me)).^2-2.*((Egam)./(me))-2)./(((Egam)./(me)).^3).*log((1+2.*((Egam)./(me))) ...
./(1+((Egam)./(me)).*(1-(1-(me)./(Egam).*((ECrit)./(Egam))./(1-(ECrit)./(Egam)))))));
end
Any help would be greatly appreciated!
0 件のコメント
採用された回答
Walter Roberson
2021 年 1 月 29 日
function Gs = Gammasigma(Egam,ECrit,sigmaT,me)
Gs = (exp(-exp(-((log(Egam)+1.2)./(.8)))-((log(Egam)+1.2)./(.8))+1)).*s3;
That invokes the function s3 without passing any input arguments.
Remember that s3 might have been written
function sigma3 = s3(me_,sigmaT_,Egam_,ECrit_)
sigma3 = s2+(3.*sigmaT_)./(8).*(1)./(((Egam_)./(me_)).^3).*(1-((Egam_)./(me_))-(1+2.*((Egam_)./(me_)))./(1+((Egam_)./(me_)) ...
.*(1-(1-(me_)./(Egam_).*((ECrit_)./(Egam_))./(1-(ECrit_)./(Egam_)))))-((Egam_)./(me_)).*(1-(me_)./(Egam_).*((ECrit_)./(Egam_))./(1-(ECrit_)./(Egam_))));
end
MATLAB absolutely will not look at the calling sequence of the function to be called and match up the formal parameter names to find the closest name in the workspace and use that as the parameter. You must explicitly pass all parameters to a function being called.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Function Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!