1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2008-2009 - INRIA - Michael Baudin
3// Copyright (C) 2011 - DIGITEO - Michael Baudin
4//
5// Copyright (C) 2012 - 2016 - Scilab Enterprises
6//
7// This file is hereby licensed under the terms of the GNU GPL v2.0,
8// pursuant to article 5.3.4 of the CeCILL v.2.1.
9// This file was originally licensed under the terms of the CeCILL v2.1,
10// and continues to be available under such terms.
11// For more information, see the COPYING file which you should have received
12// along with this program.
13
14// <-- ENGLISH IMPOSED -->
15
16
17function [ y , index ] = rosenbrock ( x , index )
18  y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
19endfunction
20
21// Use 20 points in X and 20 points in Y
22NP = 20;
23
24//
25// Test a basic contour plot
26//
27nm = nmplot_new ();
28nm = nmplot_configure(nm,"-numberofvariables",2);
29nm = nmplot_configure(nm,"-function",rosenbrock);
30xmin = -2.0;
31xmax = 2.0;
32ymin = -2.0;
33ymax = 2.0;
34nx = NP;
35ny = NP;
36[nm , xdata , ydata , zdata ] = nmplot_contour ( nm , xmin , xmax , ymin , ymax , nx , ny );
37f = scf();
38drawlater();
39contour ( xdata , ydata , zdata , [1 10 100 500 1000 2000] );
40drawnow();
41close(f);
42nm = nmplot_destroy(nm);
43
44
45// Test with a function for which the column orientation matters
46function [ y , index ] = myquad ( x , index )
47  y = x' * x;
48endfunction
49
50// Use 20 points in X and 20 points in Y
51NP = 20;
52
53//
54// Test a basic contour plot
55//
56nm = nmplot_new ();
57nm = nmplot_configure(nm,"-numberofvariables",2);
58nm = nmplot_configure(nm,"-function",myquad);
59xmin = -2.0;
60xmax = 2.0;
61ymin = -2.0;
62ymax = 2.0;
63nx = NP;
64ny = NP;
65[nm , xdata , ydata , zdata ] = nmplot_contour ( nm , xmin , xmax , ymin , ymax , nx , ny );
66f = scf();
67drawlater();
68contour ( xdata , ydata , zdata , linspace(0,8,20) );
69drawnow();
70close(f);
71nm = nmplot_destroy(nm);
72
73
74