[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 0-1 function
From: |
Geordie McBain |
Subject: |
Re: 0-1 function |
Date: |
Tue, 8 Mar 2005 03:19:22 +1100 |
User-agent: |
Mutt/1.5.6+20040907i |
On Sun, Mar 06, 2005 at 10:03:40PM +0100, Gorazd Brumen wrote:
> Hi again,
>
> I have a function of 2 variables which takes only the values
> 0 and 1. What would be in your oppinion
> the best way to present this
> function graphically? If I draw a mesh plot or a contour
> plot, gnuplot always wants to make graphs continuous and
> they look weird.
>
> Gorazd
Hello. One way is to colour-in the region f=1. For example
octave> function p = pred (x, y); p = y < sqrt (abs (x) + x.**2); endfunction
octave> [XX, YY] = meshgrid (linspace (-2, 2, 100), linspace (3, 0, 100));
octave> imagesc (pred (XX, YY))
warning: in fopen near line 197, column 11:
warning: fopen: default open mode is now binary
This draws a somewhat pixellated black-and-white plot of the function
pred. (Note that the y-coordinates are reversed.)
Another way to display a function f(x,y) -> {0,1} is to draw the
margin separating the regions f=0 and f=1. This involves a lot less
function evaluations that the first method. I came up with an
algorithm to walk along such marginal curves, given two initial
points, one on either side of the curve. If this is of interest, see
http://www.aeromech.usyd.edu.au/~mcbain/stability/skirting.html
for the m-file, or
http://anziamj.austms.org.au/V45/CTAC2003/McBa/
for detailed description, theory, examples, etc.
This could also be useful for that question from someone else over the
weekend about drawing tricky contours. Say you wanted to draw the
level-curve f(x,y) = z0, define a function p(x,y)=(f(x,y)<z0), then
p(x,y) takes only two values and proceed as above.
Geordie McBain
www.aeromech.usyd.edu.au/~mcbain
-------------------------------------------------------------
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
-------------------------------------------------------------
- 0-1 function, Gorazd Brumen, 2005/03/06
- Re: 0-1 function,
Geordie McBain <=