How to run Octave code without the Octave IDE (similarly to Python)? [duplicate]

佐手、 提交于 2021-02-08 09:50:29

问题


Context: When I use Python + matplotlib, I can compose the code in any text editor (like Sublime Text), do CTRL+B, and then the text output appears in the "Build results" panel of the text editor, and, optionally, graph/plots are rendered in a new GUI window.
Under the hood, the text editor calls python myscript.py when we do "Build", and that's it.

It's simple and working flawlessly, easily.


Now I'm trying to do the same with GNU Octave: write a test.m code (such as this one). Then run it from my favorite text editor (and not the Octave IDE), or from command-line. I tried:

  • octave test.m: the plot is displayed during 100 ms and then disappears! not OK

  • octave --persist test.m: the plot stays displayed, this is ok ... but this part is not good: it opens an IDE (which I don't want since I want to continue using my usual text editor!), see the background window:

How to have GNU Octave behave like expected: the text output in stdout (either in terminal or in the "Build Results" panel of your text editor) and the plot output in a new window? Important: without spawning an IDE window.

I find strange that this behaviour is not the default behaviour. Shouldn't it be?


Edit: solved with:

octave-cli test.m

and

k = plot(...)
waitfor(k)

回答1:


to have a similar effect I run the command line interface octave-cli or octave --no-gui in a terminal and vim in a different one.
Not exactly what you are looking for, but matplotlib is a python module while octave is a separate program from your editor.

See example of the two terminals and the graphs, all on separate windows.



来源:https://stackoverflow.com/questions/66054173/how-to-run-octave-code-without-the-octave-ide-similarly-to-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!