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)

采纳的回答

Voss
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 CenterFile Exchange 中查找有关 Whos 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by