ERROR Not enough input arguments.

조회 수: 1 (최근 30일)
UserG UserG
UserG UserG 2021년 6월 11일
댓글: UserG UserG 2021년 6월 11일
Hi everyone, i am new in matlab so i dont know much.
i tried as a beginner to run this code but an error occurs saying "Not enough input arguments." What should i change?
function y=f11(x)
y=2*x+5;
end

채택된 답변

John D'Errico
John D'Errico 2021년 6월 11일
편집: John D'Errico 2021년 6월 11일
You DON'T "run" a function. Run applies to scripts, and soon you will almost forget the run command ever existed, or so I hope.
You can use a function in your code, and in any code you write. For example, define that function, and save it to your search path as an m-file.
Now, USE IT! For example, at the command line in MATLAB:
f11(3)
ans = 11
Or like this:
u = 1:5;
z = f11(u)
z = 1×5
7 9 11 13 15
Or, as long as f11 is on your search path, you can now call it in some other function. In this next example, I'll use it inside a function handle:
f22 = @(x) 2*f11(x)
f22 = function_handle with value:
@(x)2*f11(x)
f22(3)
ans = 22
So f22 takes the result of f11 applied to x, and then multiplies that by 2.
function y=f11(x)
y=2*x+5;
end
  댓글 수: 1
UserG UserG
UserG UserG 2021년 6월 11일
thank u very much.Now i understand.It worked !

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by