Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a function using Octave from terminal

I want to run a function - let's say test - inside my test.m file. I want to run this function using Octave from terminal. So, it should be something like:

$>/Users/me/octave/bin/octave test(param1,param2)?

How can I accomplish this? I can do that in Matlab. But I didn't find a way in Octave.

like image 266
rajan sthapit Avatar asked May 15 '26 00:05

rajan sthapit


2 Answers

You can use octave --eval CODE

like image 143
Oli Avatar answered May 18 '26 15:05

Oli


Octave's docs on this can be found here. To run a function with input args:

  1. In Terminal cd to your working directory.
  2. Type octave to open an interactive session.
  3. ls to check that your function's file is in your working dir, cd to the dir if not.
  4. Type the function's name immediately followed by the input args in brackets in the correct order, Eg: >foo(100). Your function will then run, spitting out whatever you print as well as all the results for lines of code not ending with ;.
like image 24
CubeBot88 Avatar answered May 18 '26 15:05

CubeBot88



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!