Questions tagged [octave]

GNU Octave is a free and open-source mathematical software package and scripting language. The scripting language is intended to be compatible with MATLAB, but the two packages are not interchangeable. Don’t use both the [matlab] and [octave] tags, unless the question is explicitly about the similarities or differences between the two.

GNU Octave is a high-level interpreted scripting language, primarily intended for numerical computations. It provides capabilities for the numerical solution of linear and nonlinear problems, and for performing other numerical experiments. It also provides extensive graphics capabilities for data visualization and manipulation. Octave has a modular framework that allows it to utilize hardware such as GPUs, parallel compute clusters, and physical sensors.

Octave is normally used through its interactive command line interface, but it can also be used to write non-interactive programs. It is quite similar to Matlab, so many programs are easily portable.

It is extensible and customizable via user-defined functions written in Octave's own language, or via dynamically loaded modules written in C++, C, Fortran, or other languages.

Octave Online is a free GNU Octave editor and prompt in your browser. Octave Online is powered by the open-source GNU Octave project, whose syntax is mostly compatible with Matlab.

###Resources

5227 questions
287
votes
9 answers

Differences between Octave and MATLAB

I'm a programmer who knows Python, Ruby and some C who is trying to decide whether to learn GNU Octave or MATLAB. I know that they have a lot in common, but it isn't clear to me how similar the syntax is or even the data structures are. The above…
lswim
  • 3,064
  • 2
  • 15
  • 13
139
votes
15 answers

Octave-Gnuplot-AquaTerm error: set terminal aqua enhanced title "Figure 1"...unknown terminal type"

I've installed Octave and gnuplot via Homebrew, and downloaded AquaTerm.dmg. When I try to plot, I get the following message: octave:4> plot(x,y) gnuplot> set terminal aqua enhanced title "Figure 1" font "*,6" ^ `line 0:…
PGreen
  • 3,239
  • 3
  • 24
  • 29
95
votes
3 answers

Octave / Matlab: Extend a vector making it repeat itself?

Is there a way to extend a vector by making it repeat itself? >v = [1 2]; >v10 = v x 5; %x represents some function. Something like "1 2" x 5 in perl Then v10 would be: >v10 1 2 1 2 1 2 1 2 1 2 This should work for the general case, not just…
Tom
  • 43,810
  • 29
  • 138
  • 169
91
votes
2 answers

cocktail party algorithm SVD implementation ... in one line of code?

In a slide within the introductory lecture on machine learning by Stanford's Andrew Ng at Coursera, he gives the following one line Octave solution to the cocktail party problem given the audio sources are recorded by two spatially separated…
gregS
  • 2,580
  • 5
  • 28
  • 33
85
votes
11 answers

Why/when should I prefer MATLAB over Octave?

In our shoestring operation we need to prototype algorithms in some higher-level language before committing to a C implementation on embedded hardware. So far we have been using MATLAB to do that, but the licensing costs are beginning to hurt. We're…
lindelof
  • 34,556
  • 31
  • 99
  • 140
82
votes
6 answers

How to concat string + i?

for i=1:N f(i) = 'f'+i; end gives an error in MatLab. What's the correct syntax to initialize an array with N strings of the pattern fi? It seems like even this is not working: for i=1:4 f(i) = 'f'; end
simpatico
  • 10,709
  • 20
  • 81
  • 126
77
votes
3 answers

Octave/Matlab: Adding new elements to a vector

Having a vector x and I have to add an element (newElem) . Is there any difference between - x(end+1) = newElem; and x = [x newElem]; ?
URL87
  • 10,667
  • 35
  • 107
  • 174
75
votes
10 answers

Plot window not responding

I'm using Windows 7 64 bit. Each time, I'm using plot function, plot windows will shows and draws successfully, but after that it stops responding and must shut down it. For example : x = linspace(0,1,10) y = x.^2 plot(x,y); Strangely, when plot…
hqt
  • 29,632
  • 51
  • 171
  • 250
73
votes
31 answers

What is your favourite MATLAB/Octave programming trick?

I think everyone would agree that the MATLAB language is not pretty, or particularly consistent. But nevermind! We still have to use it to get things done. What are your favourite tricks for making things easier? Let's have one per answer so people…
Matt
  • 5,522
  • 5
  • 29
  • 24
66
votes
8 answers

Octave does not plot

When I try to plot a graph on GNU Octave, and try to use plot, it gives me the following output set terminal aqua enhanced title "Figure 1" size 560 420 font "*,6" dashlength 1 ^ line 0: unknown or ambiguous terminal type;…
user2472071
  • 767
  • 1
  • 6
  • 11
66
votes
7 answers

How to insert a column/row of ones into a matrix?

Suppose that we have a 3x3 matrix like b = 2 * eye(3); ans = 2 0 0 0 2 0 0 0 2 and I want to a 3x4 matrix like 1 2 0 0 1 0 2 0 1 0 0 2 What is the best way to get it?
RubenLaguna
  • 21,435
  • 13
  • 113
  • 151
58
votes
10 answers

Cost Function, Linear Regression, trying to avoid hard coding theta. Octave.

I'm in the second week of Professor Andrew Ng's Machine Learning course through Coursera. We're working on linear regression and right now I'm dealing with coding the cost function. The code I've written solves the problem correctly but does not…
OhNoNotScott
  • 824
  • 2
  • 9
  • 12
55
votes
4 answers

How do I detect if I'm running MATLAB or Octave?

I need to write code that should run equally well in Octave and on MATLAB. Problem is that it needs to do some GUI stuff, which MATLAB and Octave handle completely differently. Is there a way I can detect if I'm running MATLAB or Octave, in order to…
lindelof
  • 34,556
  • 31
  • 99
  • 140
55
votes
4 answers

Remove a column from a matrix in GNU Octave

In GNU Octave, I want to be able to remove specific columns from a matrix. In the interest of generality. I also want to be able to remove specific rows from a matrix. Suppose I have this: mymatrix = eye(5) mymatrix = Diagonal Matrix 1 0 …
Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
55
votes
8 answers

Octave : logistic regression : difference between fmincg and fminunc

I often use fminunc for a logistic regression problem. I have read on web that Andrew Ng uses fmincg instead of fminunc, with same arguments. The results are different, and often fmincg is more exact, but not too much. (I am comparing the results…
hqt
  • 29,632
  • 51
  • 171
  • 250
1
2 3
99 100