help-octave
[Top][All Lists]
Advanced

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

Re: contour and contourf


From: Donald J Bindner
Subject: Re: contour and contourf
Date: Mon, 3 Apr 2006 15:59:28 -0500
User-agent: Mutt/1.5.9i

On Mon, Apr 03, 2006 at 10:34:43AM -0500, Alexandre Ribeiro wrote:
> hi!
> 
> I whould like to use octave to make a contour plot. When I use x,y and z 
> with the same size an error occurs. I want to make a contourf (contour 
> filled) plot in color, is it possible?
> 
> Tanks
> 
> Alexandre
> 
> octave:38> size(x),size(y),size(z)
> ans =
> 
>  1891     1
> 
> ans =
> 
>  1891     1
> 
> ans =
> 
>  1891     1
> 
> octave:39> contour(x,y,z)
> error: contour: columns(z) must be the same as length(x) and
> rows(z) must be the same as length(y),
> or x, y, and z must be matrices with the same size
> error: evaluating if command near line 79, column 2
> error: evaluating if command near line 76, column 7
> error: evaluating if command near line 72, column 5
> error: evaluating if command near line 39, column 3
> error: called from `contour' in file 
> `/usr/share/octave/2.1.72/m/plot/contour.m'

Contour behaves differently when passed vectors as when passed
matrices.  The usual usage is to pass matrices generated by
meshgrid().  For example, to plot the contour plot of x^2-y^2,
on the rectange [-10,10]x[-10x10] you might do:

octave:1> [x,y] = meshgrid( -10:.25:10 );
octave:2> contour(x,y, x.^2-y.^2 )

The mesh() function is the same way.  On occasion I have forced
things to work, by doubling the existing data to matricize it
(for plots of parameterized curves), as in

 xx = [x,x]; yy = [y,y]; zz = [z,z];
 mesh(xx,yy,zz);

but that is almost certainly not what you want.

Don

-- 
Don Bindner <address@hidden>



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

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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