필터 지우기
필터 지우기

Not enough input arguments when they are already defined

조회 수: 2 (최근 30일)
N/A
N/A 2022년 4월 11일
댓글: Voss 2022년 4월 11일
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
  댓글 수: 2
N/A
N/A 2022년 4월 11일
AH! I see my error, thank you for your help!
Voss
Voss 2022년 4월 11일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (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