[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie question

From: Henry F. Mollet
Subject: Re: Newbie question
Date: Thu, 04 Aug 2005 15:57:19 -0700
User-agent: Microsoft-Entourage/

I've recently pointed out a similar problem with respect to contourf(z) in
octave-forge. The output is sent to Preview and I don't understand why.
octave:62> gset term aqua 0
octave:63> [x,y] = meshgrid(linspace(-2,2,200));
octave:64> z = sinc(sqrt(x.^2 + y.^2));
octave:65> contourf(z);
error: expecting integer index, found 7.300000
error: evaluating argument list element number 1
error: called from `contourf' in file

octave:65> contourf(z); % works when used for the second time and output
appears in Preview rather than Aquaterm.

## contourf(z,n,w)
## Plots a filled contour plot of n levels using the current
## colormap.  The width w is the width of the convolution window
## which smooths the contours.
## E.g.,
##     [x,y] = meshgrid(linspace(-2,2,200));
##     z = sinc(sqrt(x.^2 + y.^2)) + 0.5*randn(size(x));
##     contourf(z);
## Note that the algorithm computes incorrect contours near the
## edges, which you can see using contourf(sinc(sqrt(x.^2+y.^2)))
## with x,y from above.

## This program is in the public domain
## Author: Paul Kienzle <address@hidden>

function contourf(z,n,w)
  if nargin < 3, w = 16; end
  if nargin < 2, n = 10; end
  if nargin < 1 || nargin > 3
    usage("contourf(z [, n [, w]])");

  ## convolute the original with a gaussian if desired
  if w > 0
    [x,y] = meshgrid(2.5*linspace(-1,1,w));
    B = exp(-.5*(x.^2+y.^2));
    z = filter2(B,z,"same");

  ## find the contours
  C = colormap;
  z = filter2(ones(2)/4,imagesc(z));
  z(z!=fix(z)) = 0;

  ## plot the image, with the contours drawn in black.
  colormap([0,0,0; C(linspace(1,rows(C),n+1),:)]);

  ## restore the colormap

on 8/4/05 2:17 PM, Melvyn Poore at address@hidden wrote:

> Hi folks, I¹m new on the block, so forgive me for asking beginner¹s
> questions.  I¹ve installed Octave 2.1.71, Gnuplot, Aqua and X11 on my Mac Ti
> Powerbook 550MHz, OSX 10.4.2.  It all appears to function as it should.
> That was already quite an achievement!
> I¹m working on some sound analysis examples and want to put the waveform and
> spectrogram plots together in a two-plot diagram.  This doesn¹t seem to work
> because plot() sends its results out via Aqua whereas the output of
> imagesc() appears in a Mac Preview window.  Am I missing some terminal
> setting or something?  I¹ve already set the line
> __gnuplot_set__ term aqua
> in startup/octaverc.
> Any help would be appreciated!
> Melvyn

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]