Not enough input arguments error in matlab

This is my matlab code , I got Not enough input argument error in line 2 and i don't know how to fix it. Anyhelp ? Thanks in advance.
function [] = Integr1( F,a,b )
i = ((b - a)/500);
x = a;k = 0; n = 0;
while x <= b
F1 = F(x);
x = x + i;
F2 = F(x);
m = ((F1+F2)*i)/2;
k = k +m;
end
k
x = a; e = 0; o = 0;
while x <= (b - 2*i)
x = x + i;
e = e + F(x);
x = x + i;
o = o + F(x);
end
n = (i/3)*(F(a) + F(b) + 2*o + 4*e)

댓글 수: 1

You forgot to give us the error message. You snipped out just a small, almost worthless, part of it. Please copy and paste the ENTIRE error message - that means ALL THE RED TEXT , not just some of it.

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

답변 (1개)

Star Strider
Star Strider 2015년 3월 10일

0 개 추천

I ran the essence of your code (I didn’t run it as a function) and it ran for me without error.
Check the way you called your function.

댓글 수: 4

Meme
Meme 2015년 3월 10일
would you please tell me exactly the inputs you used when calling the function in the command window and how did you call it exactly. Sorry i am new to matlab and thank you very much for your answer.
I didn’t actually call your function because I didn’t want to create (and then delete) another function file.
I used:
F = @(x) sin(x).^2;
a = 0;
b = 2*pi;
I would call it as:
Integr1( F,a,b )
You’re not returning anything from your function, so it will just print out ‘k’ and ‘n’ to the Command Window.
Meme
Meme 2015년 3월 10일
thank you much for your help
My pleasure.

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

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2015년 3월 9일

댓글:

2015년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by