input argument is undefined in M-file ?

i have the code below:
function mean = avg(x,n)
mean = sum(x)/n;
when i compile, there's an error as follow:
??? Input argument "x" is undefined.
Error in ==> subim1 at 2
mean = sum(x)/n;
i wolud like to ask how can i solve this problem ? hope for help ! ^~^ !

댓글 수: 1

Walter Roberson
Walter Roberson 2013년 1월 23일
When you say "compile", do you mean you use MATLAB Compiler to build an executable?
How are you invoking the code?

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

답변 (2개)

Chanh Nguyen
Chanh Nguyen 2013년 1월 24일

0 개 추천

sorry, it's a green arrow button "Save and run" !
Walter Roberson
Walter Roberson 2013년 1월 24일

0 개 추천

Do not use "Save and run" for any function that needs input parameters. Save the routine, yes, but then you need to invoke it from the command line, passing in the parameters you need. For example, at the command line type in
avg([3 5 9 -1 14], 5)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

질문:

2013년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by