problem with sample function in matlab

1 次查看(过去 30 天)
hi,
i want to start with a sample function
1. % my first function in matlab
2. function y = FirstFct(x)
3.
4. y = x*x;
5. end
and i get this error:
Error using FirstFct (line 4) Not enough input arguments.
  1 个评论
Adib HARHOURI
Adib HARHOURI 2013-3-17
Hi John ,
You must give a value for x
so try for example (on the command window) :
>>FirstFct(5)
>>y
you should get y=25

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2013-3-17
How are you starting up your function? It appears that you might be using F5 or using Run from the menus. To run a function that takes input arguments, you need to go to the command line and enter the call there, giving the inputs on that line. For example,
FirstFct(12303)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by