3

If I type octave on terminal and then:

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

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?

I'm working on Ubuntu 12.04, 32 bit

1 Answer 1

5

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.

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.

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.