Not enough input arguments when they are already defined
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I created a new function and function file "theiss", I need to call the function in another script "Part1" with defined input variables but keep getting "Not enough input arguements" on the "Part 1" file. I do not want to set default inputs on the original function. First code below is the function file with the name "theiss.m", then the next, seperate script "Part 1" is below it
thank you
function [ux] = theiss(r,S,T,t)
ux = theiss((r^2 *S)/(4 * T * t));
end
%Part1 which is a seperate script file
T = 4706;
S= 0.00072;
t = 14610 ;
r = 7500 ;
ux = theiss(7500,0.00072,4706,14610);
% I have also tried
T = 4706;
S= 0.00072;
t = 14610 ;
r = 7500 ;
[ux] = theiss(r,S,T,t)
0 个评论
采纳的回答
Voss
2022-4-11
Your function theiss calls itself with one input; that's the reason for the error.
function [ux] = theiss(r,S,T,t)
% theiss calls theiss here, with one input, which has value (r^2 *S)/(4 * T * t):
ux = theiss((r^2 *S)/(4 * T * t));
% so in that call to theiss, arguments S, T, and t are not given and you get
% the error when it tries to do (r^2 *S)/(4 * T * t) for the next call to
% theiss ...
end
Perhaps the function should be defined as:
function [ux] = theiss(r,S,T,t)
% just calculate ux and return it
ux = (r^2 *S)/(4 * T * t);
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!