1// 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3// Copyright (C) ENPC 4// Copyright (C) DIGITEO - 2010 - Allan CORNET 5// 6// This file is distributed under the same license as the Scilab package. 7// 8 9function demo_contourf2() 10 11 my_handle = scf(100001); 12 clf(my_handle,"reset"); 13 14 15 16 function z=peaks(x,y) 17 x1=x(:).*.ones(1,size(y,"*")); 18 y1=y(:)'.*.ones(size(x,"*"),1); 19 z = (3*(1-x1).^2).*exp(-(x1.^2) - (y1+1).^2) ... 20 - 10*(x1/5 - x1.^3 - y1.^5).*exp(-x1.^2-y1.^2) ... 21 - 1/3*exp(-(x1+1).^2 - y1.^2) 22 endfunction 23 24 function z=peakit() 25 // pour avoir un truc voisin de matlab avec 80 points 26 x=-4:0.1:4;y=x;z=peaks(x,y); 27 endfunction 28 29 z=peakit(); 30 levels=[-6:-1,-logspace(-5,0,10),logspace(-5,0,10),1:8]; 31 m=size(levels,"*"); 32 n = fix(3/8*m); 33 r = [(1:n)'/n; ones(m-n,1)]; 34 g = [zeros(n,1); (1:n)'/n; ones(m-2*n,1)]; 35 b = [zeros(2*n,1); (1:m-2*n)'/(m-2*n)]; 36 h = [r g b]; 37 my_handle.color_map = h; 38 xset("fpf"," "); 39 clf(); 40 41 contourf([],[],z,[-6:-1,-logspace(-5,0,10),logspace(-5,0,10),1:8], zeros(1,m)) 42 xset("fpf",""); 43 halt(_("Press Return to continue ... \n")); 44 45 if is_handle_valid(my_handle) == %f then 46 return; 47 end 48 49 clf(); 50 contourf([],[],z,[-6:-1,-logspace(-5,0,10),logspace(-5,0,10),1:8]); 51 demo_viewCode("contourf2.dem.sce"); 52 53endfunction 54 55demo_contourf2(); 56clear demo_contourf2; 57