八度不会从外部文件绘制 [英] Octave doesn't plot from external file

查看:60
本文介绍了八度不会从外部文件绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在终端上键入 octave ,然后:

If I type octave on terminal and then:

x = linspace(0, 2*pi, 100);
y = sin(x);
plot(x, y);

该图形正确显示了该图. 那就是我尝试的方法:我创建了一个名为 gettingStarted.m 的文本文件,在其中写入了上面的三行内容,以便使用Octave执行该文件. 我键入 octave GettingStarted.m ,但该图未出现. 如果您使用Octave运行外部文件,则无法打印工作?

the graphic correctly shows the plot. That's what I tried: I created a text file named gettingStarted.m where I wrote the three lines above inside of it, in order to execute this file with Octave. I type octave gettingStarted.m but the plot doesn't appear. Does not plotting work if you run an external file with Octave?

我正在使用32位Ubuntu 12.04

I'm working on Ubuntu 12.04, 32 bit

推荐答案

如果您正在运行包含绘图命令的Octave脚本,则脚本完成后,Octave也将运行.当然,这将关闭绘图窗口.请记住,绘图窗口也是八度,所以当处理结束时,另一个窗口也是如此.这样,绘图窗口确实会出现,但是在Octave完成执行后会立即关闭.

If you are running an Octave script that includes a plotting command, once the script finishes, so does Octave. This will of course close the plot window. Remember that the plot window is also Octave, so when process end, so does the other. So the plot window does show up, but immediately closes when Octave finishes execution.

一个常见的解决方案是在脚本的末尾放置一个pause命令.要在特定时间段内查看绘图窗口并自动关闭该窗口,请使用pause(n),其中

A common solution is to put a pause command at the end of your script. To view the plot window for a specific amount of time and close the window automatically use pause(n) which pauses the execution for n seconds before continuing.

一种不太理想的替代方法是使用octave --persistent path-to-script调用脚本以最终进行交互.

A less ideal alternative, is to call the script with octave --persistent path-to-script to go interactive at the end.

另请参阅Octave的FAQ条目当我尝试从脚本进行绘图时,为什么是我我什么都没看到吗?

See also, Octave's FAQ entry, When I try plotting from a script, why am I not seeing anything?

这篇关于八度不会从外部文件绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆