Not enough input arguments
이전 댓글 표시
Hello there!
I am writing a simple function but I can not understand why it will not work.
The error says "Not enough input arguments", right when the compiler is compiling the function I called ecc_anomaly.
Could you help me? I know the code is banal, though I can not fix it!
Thank you in advance!
The infamous function
function E = ecc_anomaly(tow, toe, GM, sqrta, M0, ecc)
i = 0;
M = M0+(tow-toe)*sqrt(GM/sqrta^6);
a = M0;
while i >= 10^-13
E = M0+ecc*sin(a);
i = abs(E-a);
a = E;
end
end
And finally my main
clc
clear all
format long
GM = 3.986005e14; % m^3/s^2
rotation = 7.2921151467e-5; % rad/s
tow = 223221; % s (self-check value)
%tow = 225445; % s
M0 = 1.94850072201; % rad
sqrta = 0.544062105942e+04; % m^0.5
ecc = 0.404827296734e-04; % unitless
toe = 0.225600000000e+06; % s
E = ecc_anomaly(tow, toe, GM, sqrta, M0, ecc);
f = t_a(ecc, E);
r = sqrta^2*(1-ecc*cos(E));
x_1 = r*cos(f);
x_2 = r*sin(f);
댓글 수: 3
Steven Lord
2019년 3월 11일
Can you show us the exact text of the error message (everything displayed in red text)? The exact text will likely include more information about the specific location where the error occurs.
Though I wouldn't have expected the error you received; when I ran the code it gave me a different error. Inside your ecc_anomaly function you start off with i equal to 0 and then loop while i is greater than or equal to 1e-13. Since 0 is not greater than or equal to 1e-13, MATLAB never enters the while loop and so E is never assigned a value. So there may be some difference between the code you're running and the code you posted. Can you confirm that you copied and pasted both those pieces of code directly from the Editor into Answers?
john_arle
2019년 3월 11일
Adam Danz
2019년 3월 11일
This version does not produce an error within the ecc_anomaly() funciton. It returns
E = 1.948538350699015
채택된 답변
추가 답변 (1개)
Guillaume
2019년 3월 11일
>> ecc_anomaly
Calls ecc_anomaly with no inputs argument. So, yes, you will get a "Not enough input arguments." error.
I'm not sure what else you expected to happen when you wrote that. Considering that you wrote: "right when the compiler is compiling the function I called ecc_anomaly", maybe you expected it to somehow compile the function. Base matlab does not include a compiler and if you do have matlab compiler, that's certainly not the way to go. The above simply call the function.
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!