Fix some demos errors/warnings #2 61/18861/3
Paul Bignier [Mon, 9 Jan 2017 16:47:31 +0000 (17:47 +0100)]
 * About diazepam.dem.sce: there was a bug in Scilab5, fixed in 6 so simply removed the instruction

Change-Id: I874665ab87d6ee53102ba04aa30bf508ad492dc2

scilab/modules/genetic_algorithms/demos/GAdemo.sce
scilab/modules/graphics/demos/anim/anim1/anim1.sce
scilab/modules/graphics/demos/basic_functions/basic_functions_3.dem.sce
scilab/modules/graphics/demos/basic_functions/basic_functions_5.dem.sce
scilab/modules/graphics/demos/fec/fec.ex2.dem.sce
scilab/modules/graphics/demos/fec/fec_demo.sci
scilab/modules/gui/demos/uicontrol_LaTeX.dem.sce
scilab/modules/optimization/demos/neldermead/neldermead.dem.gateway.sce
scilab/modules/optimization/demos/neldermead/neldermead_dimension.sce
scilab/modules/xml/demos/diazepam.dem.sce

index e5501e3..be19aae 100755 (executable)
@@ -118,9 +118,9 @@ function demo_genetic_algo()
     // Genetic Algorithm for binary codage //
     /////////////////////////////////////////
     clear f;
-    deff("y=f(x)","BinLen = get_param(ga_params,''binary_length''); ..
-    tmp  = convert_to_float(x, BinLen, Max, Min); ..
-    y    = "+func+"(tmp);","n");
+    deff("y = f(x)", "BinLen = get_param(ga_params, ''binary_length'');"+..
+    "tmp  = convert_to_float(x, BinLen, Max, Min);"+..
+    "y    = "+func+"(tmp);");
 
     ga_params = add_param(ga_params, "binary_length", 8);
     ga_params = set_param(ga_params, "crossover_func", crossover_ga_binary);
index a613900..ff58cd4 100644 (file)
@@ -40,18 +40,18 @@ function demo_anim1()
     st=2;
     T=35:st:80; //Theta
     A=45:st:80;  //Alpha
-    Angles=[T A(1)*ones(A);T(1)*ones(T) A];
+    Angles=[T A(1)*ones(A);T(1)*ones(T) A]';
 
     //animation loop
     //--------------
     //use realtime to slow down the loop
     realtimeinit(0.1);//set time step and date reference
-    for i=1:size(Angles,2) // loop on theta angle
+    for i=1:size(Angles,1) // loop on theta angle
         realtime(i); //wait till date 0.1*i seconds
         if ~is_handle_valid(curAxe) then
             break
         end
-        curAxe.rotation_angles = Angles(:,i); //change the view angles property
+        curAxe.rotation_angles = Angles(i,:); //change the view angles property
     end
 
 endfunction
index 33e4e65..1bf0a41 100644 (file)
@@ -50,37 +50,36 @@ function demo_basic_function3()
     execstr(expr);
 
     // Demo III.3
-    expr=["xset(''line style'',1);";
-    "xget(''line style'',1);";
+    expr=["a.line_style = 1;";
     "xrect(140,470,120,170);"];
     messagebox(["[III.3] Setting a dash style";expr],"modal");
     execstr(expr);
 
     // Demo III.4
-    expr=["xset(''font'',2,0);";
-    "xstring(0,130,''Scilab'');";
-    "xset(''font'',2,1);";
+    expr=["xstring(0,130,''Scilab'');";
+    "e = gce(); e.font_style = 2; e.font_size = 0;";
     "xstring(0,150,''Scilab'');";
-    "xset(''font'',2,2);";
+    "e = gce(); e.font_style = 2; e.font_size = 1;";
     "xstring(0,170,''Scilab'');";
-    "xset(''font'',2,3);";
+    "e = gce(); e.font_style = 2; e.font_size = 2;";
     "xstring(0,200,''Scilab'');";
-    "xset(''font'',2,4);";
+    "e = gce(); e.font_style = 2; e.font_size = 3;";
     "xstring(0,230,''Scilab'');";
-    "xset(''font'',2,5);";
+    "e = gce(); e.font_style = 2; e.font_size = 4;";
     "xstring(0,270,''Scilab'');";
-    "xset(''font'',3,5);";
+    "e = gce(); e.font_style = 2; e.font_size = 5;";
     "xstring(0,310,''Scilab'');";
-    "xset(''font'',4,5);";
-    "xstring(0,350,''Scilab'');"]
+    "e = gce(); e.font_style = 3; e.font_size = 5;";
+    "xstring(0,350,''Scilab'');";
+    "e = gce(); e.font_style = 4; e.font_size = 5;";]
     messagebox(["[III.4] Setting font style and size";expr],"modal");
     execstr(expr);
 
     // Demo III.5
-    expr=["xset(''line mode'',0);";
+    expr=["a.line_mode = 0;";
     "xlfont(''SansSerif'',6);";
-    "xset(''font'',6,3);";
-    "xstring(100,260,''helVB'',0,1);"];
+    "xstring(100,260,''helVB'',0,1);";
+    "e = gce(); e.font_style = 6; e.font_size = 3;";];
     messagebox(["[III.5] Loading a new font hlevB is now font 6";expr],"modal");
     execstr(expr);
 
@@ -89,22 +88,22 @@ function demo_basic_function3()
     "[n1,n2]=size(x1);";
     "y1=300*ones(x1);"];
     expr=[expr0;
-    "xset(''mark'',6,2);";
+    "a.mark_style = 6; a.mark_size = 2;";
     "xpoly(x1,y1,''marks'',0);"];
     messagebox(["[III.6] changing current mark";expr],"modal");
     execstr(expr);
 
     // Demo III.7
     expr=[expr0;
-    "xset(''mark'',7,2);";
+    "a.mark_style = 7; a.mark_size = 2;";
     "xpoly(x1,y1+50*ones(x1),''marks'',0);";
-    "xset(''mark'',8,3);";
+    "a.mark_style = 8; a.mark_size = 3;";
     "xpoly(x1,y1+100*ones(x1),''marks'',0);"];
     messagebox(["[III.7] changing current mark";expr],"modal");
     execstr(expr);
 
     // Demo III.8
-    expr=["xset(''thickness'',5);";
+    expr=["a.thickness = 5;";
     "xrect(400,200,50,100);";];
     messagebox(["[III.8] Thickness)";expr],"modal");
     execstr(expr);
index aa8405d..f2b48e3 100644 (file)
@@ -25,7 +25,7 @@ function demo_basic_function5()
     "a.clip_state = ''clipgrf'';"
     "x=[-1 1 1 -1 -1]'';y=[-1 -1 1 1 -1]'';"
     "xx=x*(n-1);yy=y*(n-1);"
-    "for k=2:n,;"
+    "for k=2:n"
     "  xx=[xx,x*((n-k))]; yy=[yy,y*(n-k)];"
     "end;"
     "c=0:(n-1);"
index f7b0d41..733852a 100644 (file)
@@ -22,28 +22,28 @@ function demo_fec_example2()
     drawlater();
     amdbaR(path+"MESH");
     meshvisu();
-    xtitle("a mesh");
+    xtitle("A mesh");
     a=gca();
     a.title.font_size=3;
     drawnow();
 
     //xclick();
-    messagebox("click to continue","modal");
+    messagebox("Click to continue","modal");
 
     clf(curFig,"reset");
     drawlater();
     emc2C(1,6,path+"MESH.VAL");
-    xtitle("display a fem solution");
+    xtitle("Display a fem solution");
     a=gca(); a.title.font_size=3;
     drawnow();
     //xclick();
-    messagebox("click to continue","modal");
+    messagebox("Click to continue","modal");
 
     clf();
     drawlater();
     emc2C(1,6,path+"MESH.VAL",[-2,-2,2,2]);
     emc2V(2,3,6,20,path+"MESH.VAL",[-2,-2,2,2]);
-    xtitle("display a zoom of the solution together with the velocity field");
+    xtitle("Display a zoom of the solution together with the velocity field");
     a=gca();
     a.title.font_size=3;
     drawnow();
index cdd1e0d..5b5a409 100644 (file)
@@ -92,6 +92,7 @@ function []=emc2V(i,j,k,sa,FN,rect)
     if rhs == 0 ; FN="MESH";end
     unit=file("open",FN,"old")
     resu=read(unit,noeuds,k);
+    file("close",unit);
     resu=resu(:,[i,j]);
     nm=[];
     for i=1:noeuds;
@@ -104,9 +105,7 @@ function []=emc2V(i,j,k,sa,FN,rect)
     xsegs([noeul(:,2)-(1/sa)*resu(:,1),noeul(:,2)+(1/sa)*resu(:,1)]',...
     [noeul(:,3)-(1/sa)*resu(:,2),noeul(:,3)+(1/sa)*resu(:,2)]',...
     16*ones(nm)-16*nm);
-    file("close",unit);
     xset("clipoff");
-    file("close",unit);
 
 endfunction
 
@@ -120,10 +119,9 @@ function []=emc2C(i,j,FN,rect)
     [lhs,rhs]=argn(0);
     unit=file("open",FN,"old");
     resu=read(unit,-1,j);
-    resu=resu(:,i);
     file("close",unit);
+    resu=resu(:,i);
     if rhs<=3;rect=[min(noeul(:,2)),min(noeul(:,3)),max(noeul(:,2)),max(noeul(:,3))];end
     fec(noeul(:,2),noeul(:,3),trianl,resu,"031"," ",rect);
-    file("close",unit);
 
 endfunction
index deac58d..2a53b91 100644 (file)
@@ -4,24 +4,24 @@
 // This file is released under the 3-clause BSD license. See COPYING-BSD.
 
 function latex_callback()
-    messagebox("LaTeX is beautiful !", "", "info", "modal");
+    messagebox("LaTeX is beautiful!", "", "info", "modal");
 endfunction
 
 function mathml_callback()
-    messagebox("MathML is beautiful !", "", "info", "modal");
+    messagebox("MathML is beautiful!", "", "info", "modal");
 endfunction
 
 // Create a figure
 f = figure( ...
-    "figure_name", gettext("Uicontrols demo with LaTeX"), ...
-    "infobar_visible", "off", ...
-    "toolbar_visible", "off", ...
-    "dockable", "off", ...
-    "menubar", "none", ...
-    "default_axes", "on", ...
-    "layout", "grid", ...
-    "layout_options", createLayoutOptions("grid", [3 1]), ...
-    "figure_position", [50 50]);
+"figure_name", gettext("Uicontrols demo with LaTeX"), ...
+"infobar_visible", "off", ...
+"toolbar_visible", "off", ...
+"dockable", "off", ...
+"menubar", "none", ...
+"default_axes", "on", ...
+"layout", "grid", ...
+"layout_options", createLayoutOptions("grid", [3 1]), ...
+"figure_position", [50 50]);
 
 // Add custom menus
 mlatex=uimenu(f,"label", '$\LaTeX$');
@@ -36,20 +36,20 @@ mm2=uimenu(mmathml, "label", "<mrow><msup><mn>a</mn><mi>2</mi></msup><mo>+</mo><
 demo_viewCode(SCI+ "/modules/gui/demos/uicontrol_LaTeX.dem.sce");
 
 uicontrol(f, ...
-    "style", "pushbutton", ...
-    "string","<math><mrow><mtext>MathML</mtext><mphantom><mi>a</mi></mphantom><msup><mi>x</mi><mn>2</mn></msup></mrow></math>", ...
-    "horizontalalignment", "center", ...
-    "Callback", "mathml_callback();", ...
-    "Fontsize", 16);
+"style", "pushbutton", ...
+"string","<math><mrow><mtext>MathML</mtext><mphantom><mi>a</mi></mphantom><msup><mi>x</mi><mn>2</mn></msup></mrow></math>", ...
+"horizontalalignment", "center", ...
+"Callback", "mathml_callback();", ...
+"Fontsize", 16);
 
 uicontrol(f, ...
-    "style", "text", ...
-    "string", "$\text{Text: }\Gamma(s)=\int_0^\infty t^{s-1}\mathrm{e}^{-t}\,\mathrm{d}t$", ...
-    "horizontalalignment", "center", ...
-    "Fontsize", 16);
+"style", "text", ...
+"string", "$\text{Text: }\Gamma(s)=\int_0^\infty t^{s-1}\mathrm{e}^{-t}\,\mathrm{d}t$", ...
+"horizontalalignment", "center", ...
+"Fontsize", 16);
 
 uicontrol(f, ...
-    "style", "pushbutton", ...
-    "string",'$\scalebox{2}{\LaTeX\ x^2}$', ...
-    "horizontalalignment", "center", ...
-    "Callback", "latex_callback();");
+"style", "pushbutton", ...
+"string",'$\scalebox{2}{\LaTeX\ x^2}$', ...
+"horizontalalignment", "center", ...
+"Callback", "latex_callback();");
index 2229c85..378fe79 100644 (file)
@@ -14,7 +14,7 @@ _("fminsearch - Plot F"),              "fminsearch_optimplotfval.sce"; ...
 _("fminsearch - Plot X"),              "fminsearch_optimplotx.sce"; ...
 _("neldermead - Rosenbrock Variable"), "neldermead_rosenbrock.sce"; ...
 _("neldermead - Output Command"),      "neldermead_outputcmd.sce"; ...
-_("neldermead - Dimensionality"),     "neldermead_dimension.sce"; ...
+_("neldermead - Dimensionality"),      "neldermead_dimension.sce"; ...
 _("nmplot - Han #1"),                  "nmplot_han1.sce"; ...
 _("nmplot - Han #2"),                  "nmplot_han2.sce"; ...
 _("nmplot - McKinnon #1"),             "nmplot_mckinnon.sce"; ...
index 2f2081d..c48e7d4 100644 (file)
@@ -75,7 +75,7 @@ function demo_dimension()
 
     // Plot rate of convergence
     hh = scf();
-    plot(1:nmax,array_rho)
+    plot(1:nmax,array_rho')
     hh.children.x_label.text = _("Number of parameters")
     hh.children.y_label.text = _("Rate of convergence")
     hh.children.children.children.mark_mode = "on";
@@ -84,7 +84,7 @@ function demo_dimension()
 
     // Plot number of function evaluations
     hh = scf();
-    plot(1:nmax,array_nbfevals)
+    plot(1:nmax,array_nbfevals')
     hh.children.x_label.text = _("Number of parameters")
     hh.children.y_label.text = _("Number of function evaluations")
     hh.children.children.children.mark_mode = "on";
index c71f6e1..ad56e6c 100644 (file)
@@ -78,7 +78,6 @@ function diazepam_demo()
             coords(:, $ + 1) = x2 + 0.1 * u;
         end
     end
-    coords = coords(:, 2:$);
 
     xsegs(coords(1, :), coords(2, :));