octave

What are your favourite MATLAB/Octave programming tricks?

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 can vote them up if they agree. Also, try to illustrate your answer with an example. ...

Increasing efficiency of loop that uses datenum function?

The following loop takes about 700 seconds to run in octave and 22 seconds to run in matlab when the DJI matrix has 21000 rows. How can I increase the efficiency of this? for i=1:length(DJI) DJI2(i,1)=datenum(char(DJI(i,2)),'yyyy-mm-dd'); end ...

Running portions of a loop in parallel with Octave?

I have the following code that I need to run over a matrix with over 20000 rows. It takes several minutes to run and the datenum and str2double functions appear to be the bottlenecks. Since no calculation depends on previous ones is there a way to break the loop into multiple parts and have them execute in parallel? Any advice on optimis...

running code with threads in Octave

I have several blocks of the following code that each use there own matrix. Is there a way to run each block in it's own thread rather then run all of them sequentially? for i=1:length(DJI) DJI2(:,1) = reshape(datenum(strvcat(DJI(:,2)(:)), length(DJI(:,2)),'yyyy-mm-dd')); DJI2(:,2:6) = reshape(str2num(strvcat(DJI(:,3:7)(:)), length(DJI...

Binning in matlab

I have been unable to find a function in matlab or octave to do what I want. I have a matrix m of two columns (x and y values). I know that I can extract the column by doing m(:,1) or m(:,2). I want to split it into smaller matricies of [potentially] equal size and and plot the mean of these matricies. In other words, I want to put th...

Is anyone using 64 bit build of Octave?

Hi, I'm wondering if anyone has a 64-bit build of Octave? If so, do you know if it has full access to the 64 bit memory range -- i.e., can you create a matrix which uses up more than 4GB of memory? Thanks, Ben ...

How can I set the window size of a plot window?

Is it possible to set the window size / position of a plot window (figure)? plot(0:20, sin(0:20)) Or is there any other possibility to change the size of the print() command? print('aa.png', '-dpng') Because the -Sxsize,ysize parameter doesn't change anything. The size of the written picture (aa.png) has always the same size as the...

Implementing Matlab's avgpower in Octave?

Folks, Matlab 2007b (7.5.0) has an avgpower function. See here: "The avgpower method uses a rectangle approximation to the integral to calculate the signal's average power using the PSD data stored in the object. "The avgpower method returns the average power of the signal which is the area under the PSD curve." Example invocation: ...

AWGN generator for .NET

I'm looking for an Additive White Gaussian Noise generator for .NET. I know that somewhere there is some degree of interoperability between .NET and MATLAB, which has a AWGN generator, but I don't know if its free EDIT and I just found it. Probably other applications as GNU Octave, which have similar functionalities to MATLAB, have .NE...

fitting parameters of ODEs while using octave/matlab ODE solver

I am using OdePkg in Octave to solve a system of stiff ODEs, e.g. by ode5r: function yprime = myODEs(t,Y,param) yprime = [ - param(1) * Y(1); # ODE for Y(1) param(1) * Y(1) - param(2) Y(2) * Y(3); # ODE for Y(2) param(2) Y(2) * Y(3) # ODE for Y(3) ...

Loading data from Excel file into Octave

I have an Excel file with a large set of data. The built-in graphs available in Excel are not enough to analyze these data, so I am thinking about using some tool like octave or R. I was thinking about some method to load an Excel file directly into octave or R. I searched the web and found that many people have succeeded using by expor...

Finding a curve to match data

I'm looking for a non-linear curve fitting routine (probably most likely to be found in R or Python, but I'm open to other languages) which would take x,y data and fit a curve to it. I should be able to specify as a string the type of expression I want to fit. Examples: "A+B*x+C*x*x" "(A+B*x+C*x*x)/(D*x+E*x*x)" "sin(A+B*x)*exp(C+D*x)+...

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. ...

Octave + GNUPlot + Aquaterm + Mac OS 10.6 -- Student Needs Help!

Greetings, I'm the only person in my Numerical Analysis class attempting to do all of the MatLab based homework assignments in Octave - the opensource representation of MatLab. However, I'm having problems getting graphs to plot and I think it's a simple linking problem. I am running: -Mac OS X Snow Leopard (10.6) -Octave 3.2.2 -Aqua...

Compiling external C++ library (Octave) for iPhone (Fortran compiler missing?)

A friend of mine asked me if it would be possible to port the Octave project to the iPhone. I haven't compiled an external package for an iPhone project before, so I downloaded the source code, and then used some scripts found on a couple of different Web sites (one, two) to try and build the libraries. However, when I try either of thes...

Is there a way to make imshow in octave behave more like Matlab?

Hello, I'm currently migrating some computer vision work I'd previously been doing in Matlab to Octave. For the most part, it's been a smooth transition, except for one annoyance. I often use the imshow() procedure to view an image. In the viewer I get in Matlab, I'm able to inspect individual pixels to see their value. For example,...

Does Gnu Octave have any existing code for drawing lines or polygons?

Background: I want to be able to take a 2d matrix (an image really), and a set of points defining a polygon, and draw that polygon into the matrix. Before I run off and reinvent the wheel, I thought I'd ask if anyone knew of any existing libraries or code in Octave that does this. So far, my searches through the Octave packages and ...

Mathematica's Tables and Modifications in Octave?

How can I do Mathematica-style a = Table[2^(2 k) + 1, {k, 1, 3}] Last[a], First[a] Append[a,3] in Octave? ...

Octave colorbar and units

In GNU Octave you can make a picture where different colors represent different values in a matrix. You can also add a colorbar, which shows what color corresponds to what value. Is it possible to somehow add units to the values shown in the colorbar? Instead of saying “0.36” it would say “0.36 V/nm”? I know this is possible in Matlab, ...

How do I play a sound in Octave?

Octave appears to assume that a specific sound playing utility will be available on a system but doesn't seem to provide the ability to specify an alternate. In the error below, Octave is looking for ofsndplay, which is not a utility available on all systems. octave:38> sound(beamformed_20) sh: ofsndplay: command not found I...