从命令行调用函数时绘制八度音程
我正在尝试从命令行运行octave 中的函数。该函数当前的运行方式如下:
octave --silent --persist --eval 'function(input arguments)'
function.m
contains a plot命令。当我使用上述命令行参数调用 Octave 时,绘图确实显示,但 Octave 进入交互模式。我的问题是:
有没有办法让八度音阶显示绘图而无需从命令行调用时进入交互模式?
I am trying to run a function in octave
from the command line. The function is currently run like so:
octave --silent --persist --eval 'function(input arguments)'
function.m
contains a plot
command. When I invoke octave
with the above command line parameters, the plot does show but octave enters into its interactive mode. My question is:
Is there any way to get octave to display the plot without entering the interactive mode when it is invoked from the command line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
只需在绘图函数之后使用
pause
Just use
pause
after your plotting functions你可以在最后使用:
,等待你关闭该图。
You can use:
at the end, which waits for you to close the figure.
AFAIK,绘图窗口是八度的子进程,因此只能在八度运行时显示。即使您在“交互”模式下绘制某些内容,让绘图保持打开状态并关闭八度音程,绘图也会消失。
您可以做的就是绘制一些输出文件,如此处发布:
AFAIK, the plot window is a child process of octave and therefor can only be displayed when octave is running. Even if you plot something from the "interactive" mode leave the plot open and close octave, the plot will also disappear.
What you could do is to plot to some output file like posted here:
您需要选择合适的图形工具包:
默认为
fltk
,它无法在不显示绘图的情况下写入文件。但是,如果您选择 gnuplot,它将能够写入文件而不先显示它。在您的文件中以以下内容开头:You need to select a proper graphics toolkit:
The default is
fltk
which cannot write to file without displaying the plot. However, if you selectgnuplot
it will be able to write to file without displaying it first. In your file start with:问题是,当您从命令行运行时,当它结束时,绘图窗口随之消失。
这会将输出保存到运行目录中的 MyPNG.png。
然后你可以用可视化程序打开它。
添加
另一种选择是在程序末尾
,以便等待用户输入终止,从而关闭绘图窗口。干杯:)
The problem is that when you run from command line, when it ends, the plot windows disappear with it.
This saves output to MyPNG.png in the directory where it is run.
Then you might open it with a visualization program.
Another option is to add
at the end of the program so it waits for user input to terminate, therefore to close the plot window.
Cheers :)
也可以尝试等待按键。
while (waitforbuttonpress()==0)
暂停(1)
结尾
Also can try wait for key.
while (waitforbuttonpress ()==0)
pause(1)
end