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
32
votes
3 answers

How can I get a list of all the defined variables in Matlab or Octave?

I'm used to working in Matlab using its full GUI environment. Due to license issues I went and installed Octave, but it appears that it doesn't have a GUI, at least not one that's installed by default. I transferred the variables from Matlab to…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
31
votes
1 answer

Does Matlab accept non-integer indices?

Of course not! ...Or does it? Let's do some tests. Define x = [10 20 30 40 50]. Then any of the following statements, as expected, gives an error in Matlab (Subscript indices must either be real positive integers or logicals): >> x(1.2) >>…
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
28
votes
3 answers

"Undefined function 'function_name' for input arguments of type 'double'."

A question that pops up quite frequently in different shapes and sizes is: Why do I get the following error message: "Undefined function 'function_name' for input arguments of type 'double'." This post attempts to address all the different…
Stewie Griffin
  • 14,889
  • 11
  • 39
  • 70
28
votes
1 answer

How to change axis linewidth and fontsize in Octave

I am trying to resize some plots in Octave. I've been able to change the line thickness and axis labels. However, I cannot find a way to make the axes themselves thicker, or the numbers larger. What I've found online uses set(), like plot(x, y,…
qstnhr
  • 281
  • 1
  • 3
  • 3
28
votes
5 answers

How to execute .m files in Octave

How do I execute .m files in Octave?
Hamed Kamrava
  • 12,359
  • 34
  • 87
  • 125
27
votes
10 answers

Plotting with Octave after most recent MAC OSX update

Hi I just recently downloaded the most recent snow leopard update. Then I tried to plot something using Octave which has been installed on my computer for months (and plotting has worked all that time) Even since I installed the update, and I try…
Clark
  • 273
  • 1
  • 3
  • 4
27
votes
2 answers

Octave position of maximum value in column

I want to find the argmax of the values in a matrix by column, e.g.: 1 2 3 2 3 3 4 5 6 -> 3 7 8 I feel like I should just be able to map an argmax/posmax function over the columns, but I don't see a particularly intuitive way to do this in…
Philip Massey
  • 1,401
  • 3
  • 14
  • 24
27
votes
9 answers

gradient descent seems to fail

I implemented a gradient descent algorithm to minimize a cost function in order to gain a hypothesis for determining whether an image has a good quality. I did that in Octave. The idea is somehow based on the algorithm from the machine learning…
Tyzak
  • 2,430
  • 8
  • 38
  • 52
26
votes
2 answers

How do you open .mat files in Octave?

I have a .mat file that I want to open and see its contents. Since I don't have MATLAB, I downloaded GNU's Octave. I'm working on Mac's terminal so I'm not exactly sure how to open the .mat file to see its contents. How to do this?
user1257724
26
votes
3 answers

How can I access a matlab/octave module from python?

I am looking for a way to access a matlab module from python. My current situation is this: I have a python code that does numerical computations by calling Lapack routines while the memory is allocated as ctypes and passed as pointers to the…
Woltan
  • 13,723
  • 15
  • 78
  • 104
26
votes
6 answers

Replace all zeros in vector by previous non-zero value

Matlab/Octave algorithm example: input vector: [ 1 0 2 0 7 7 7 0 5 0 0 0 9 ] output vector: [ 1 1 2 2 7 7 7 7 5 5 5 5 9 ] The algorithm is very simple: it goes through the vector and replaces all zeros with the last non-zero value. It seems…
Paweł Załuski
  • 498
  • 5
  • 12
26
votes
6 answers

How do I declare a symbolic matrix in Octave?

In MatLab, you can declare symbols pretty easily: syms a,b mat = [a,b] I'm getting an error, however, when I try to replicate this in Octave. This is the code I'm using: > symbols > a = sym("a") a = a > b = sym("b") b = b > mat = [a,b] error:…
TwentyMiles
  • 4,063
  • 3
  • 30
  • 37
26
votes
5 answers

How do I install a MATLAB mode in GNU Emacs?

Is there an Emacs major mode for MATLAB and / or Octave files? For those who don't know, MATLAB files generally have a ".m" file extension. My primary interest is GNU Emacs but XEmacs tips would also be appreciated.
Bob Cross
  • 22,116
  • 12
  • 58
  • 95
24
votes
1 answer

Why is reshape so fast? (Spoiler: Copy-on-Write)

I have a big matrix A which is 1GB of double values, when I reshape it to different dimensions, it's incredible fast. A=rand(128,1024,1024); tic;B=reshape(A,1024,128,1024);toc Elapsed time is 0.000011 seconds. How can it be that fast? Another…
Daniel
  • 36,610
  • 3
  • 36
  • 69
24
votes
3 answers

Why does Gnu Octave have negative zeroes?

This is an odd one I'm puzzled about. I recently noticed at the Gnu Octave prompt, it's possible to enter in negative zeroes, like so: octave:2> abomination = -0 And it remembers it, too: octave:3> abomination abomination = -0 In the interest of…
BigBeagle
  • 695
  • 1
  • 9
  • 18