Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Octave Function Undefined

Any idea why the following produces an error?

printf("this is my text\n");

MyFunc;

function MyFunc
  printf("printing from inside function\n");
endfunction

This is the error I get (from the Command Window)

error: 'MyFunc' undefined near line 3, column 3 error: called from function_example at line 3 column 1

like image 496
Sketch Avatar asked Aug 27 '26 20:08

Sketch


1 Answers

Okay, I see the issue now. The function definition needs to be placed before the function call is made - as shown below.

printf("this is my text\n");

function MyFunc
  printf("printing from inside function\n");
endfunction

MyFunc;
like image 64
Sketch Avatar answered Aug 29 '26 22:08

Sketch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!