How to Draw contour in octave

Contours are used in map creation. Let our function be: x2 + y2. Let us generate a contour map that shows the contour lines for a given function z = f(x, y). This function has two variables x and y.

octave:1> x=-6:6;

octave:1> x=-7:7;

octave:3> [x,y] = meshgrid(-6:0.1:6,-7:0.1:7); //create datasets for 2 variables. 0.1 is a incremental factor.

octave:4> z = x.^2 + y.^2;   //function according to which we will generate contour.

octave:9> [c,h]=contour(z)  //create contour. c is a no. of contour levels.

octave:9> [c,h]=contourf(z) // fill color in contour.

octave:10> set(h,’ShowText’,’on’,’TextStep’,get(h,’LevelStep’)*2) // show value at each contour line.

Screenshot from 2015-06-22 21:06:43

for more options type  octave:1> help contour on terminal. OR follow below links.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s