problem with sample function in matlab

2 Ansichten (letzte 30 Tage)
john vattic
john vattic am 17 Mär. 2013
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 Kommentar
Adib HARHOURI
Adib HARHOURI am 17 Mär. 2013
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 17 Mär. 2013
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)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by