[Scilab-users] update script to Scilab 6.00

classic Classic list List threaded Threaded
4 messages Options
Hermes Hermes
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] update script to Scilab 6.00

how to update this script to scilab 6.00. I really do not know where and how
to substitute ¨pixmap¨ for drawlater and drawnow and get the animation as
good as shown on the source website of the script

//http://www.ulb.ac.be/polytech/smana/TUTORIAL.htm
<http:////http://www.ulb.ac.be/polytech/smana/TUTORIAL.htm>  
function dy=fon(t, y)
global g l
dy(1) = y(2);
dy(2)=-g/l*sin(y(1));
endfunction
 
teta_init = 45;teta_init=teta_init/180*pi;dteta_init = 0;
g=9.81;l=1;
t=0:0.1:20;
y=ode([teta_init;dteta_init],0,[t],fon);
 
//Preparation du graphe
f = gcf(); // on recupere le handle de la fen^etre graphique
f.pixmap = "on"; // on met la fenetre en mode double buffer
f.background = color("white");
f.foreground = color("white");;
//FIN Preparation du graphe
 
i = 1;
while i<=length(y)  
  i = i+1;  
 
  clf(); // On efface l'image précédente - on évite le scintillement
  xtitle('', 'm', 'm');  
  a = gca(); // On récupère l'objet graphique axes pour modifier les
légendes
  a.isoview = "on"; a.data_bounds = [-2 2 -2 2];  a.title.text = "Le pendule
";
  a.title.font_size = 4; a.title.foreground = color("white");
  a.background = color("white");;
 
  xpoly([0  +l*sin(y(1,i))],[0 -l*cos(y(1,i))],"lines",0)
  ep = gce(); // On récupère l'objet graphique double-pendule atwood
              // pour modifier son aspect cosmétique
  ep.thickness = 3;ep.foreground = color("blue");
 
 
plot([+l*sin(y(1,i))],[-l*cos(y(1,i))],'o','MarkSize',10,'MarkBackground','b')
  xgrid(12)
  show_pixmap() // basculement de la pixmap a l'ecran
end
f.pixmap = "off"; // on remet la fen^etre en mode usuel


Gracias



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Pierre Payen Pierre Payen
Reply | Threaded
Open this post in threaded view
|

Re: update script to Scilab 6.00

function dy=fon(t,y,g,l) // get rid of global variable
dy(1) = y(2);
dy(2)=-g/l*sin(y(1));
endfunction
 
teta_init = 45;
teta_init=teta_init/180*%pi;
dteta_init = 0;
g=9.81;
l=1;
t=0:0.1:20;
y=ode([teta_init;dteta_init],0,[t],list(fon,g,l)); // pass g,l as parameter
 
//Preparation du graphe
f = gcf(); // on recupere le handle de la fen^etre graphique
f.background = color("white");
//FIN Preparation du graphe

i = 1;
xtitle('', 'm', 'm');  
a = gca(); // On récupère l'objet graphique axes pour modifier les légendes
a.isoview = "on";
a.data_bounds = [-2 2 -2 2];
a.title.text = "Le pendule";

a.title.font_size = 4;
a.title.foreground = color("white");
a.background = color("white");

xpoly([0  +l*sin(y(1,i))],[0 -l*cos(y(1,i))],"lines",0)
hline= gce(); // On récupère l'objet graphique double-pendule atwood
            // pour modifier son aspect cosmétique
hline.thickness = 3;
hline.foreground = color("blue");
 
plot([+l*sin(y(1,i))],[-l*cos(y(1,i))],'o','MarkSize',10,'MarkBackground','b')
h=gce()
hpoint=h.children
xgrid(12)

while i<=length(y)  
  i = i+1;  
  hline.data=[0,0;0+l*sin(y(1,i)),0-l*cos(y(1,i))] // update coordinate of
the polyline without clearing the figure
  hpoint.data=[+l*sin(y(1,i)),-l*cos(y(1,i))]        // same
end



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Pierre Payen Pierre Payen
Reply | Threaded
Open this post in threaded view
|

Re: update script to Scilab 6.00

This post was updated on .
In reply to this post by Hermes
function dy=fon(t,y,g,l) // get rid of global
dy(1) = y(2);
dy(2)=-g/l*sin(y(1));
endfunction
 
teta_init = 45;
teta_init=teta_init/180*%pi;
dteta_init = 0;
g=9.81;
l=1;
t=0:0.1:20;
y=ode([teta_init;dteta_init],0,[t],list(fon,g,l)); // added g,l as parameter
 
//Preparation du graphe
f = gcf(); // on recupere le handle de la fen^etre graphique
f.background = color("white");
//FIN Preparation du graphe

i = 1;
xtitle('', 'm', 'm');  
a = gca(); // On récupère l'objet graphique axes pour modifier les légendes
a.isoview = "on";
a.data_bounds = [-2 2 -2 2];
a.title.text = "Le pendule";

a.title.font_size = 4;
a.title.foreground = color("white");
a.background = color("white");

xpoly([0  +l*sin(y(1,i))],[0 -l*cos(y(1,i))],"lines",0)
hline= gce(); // On récupère l'objet graphique double-pendule atwood
            // pour modifier son aspect cosmétique
hline.thickness = 3;
hline.foreground = color("blue");
 
plot([+l*sin(y(1,i))],[-l*cos(y(1,i))],'o','MarkSize',10,'MarkBackground','b')
h=gce()
hpoint=h.children
xgrid(12)

while i<=size(y,2)  
  i = i+1;  
  hline.data=[0,0;0+l*sin(y(1,i)),0-l*cos(y(1,i))] // only updating
pendulumm coordinates
  hpoint.data=[+l*sin(y(1,i)),-l*cos(y(1,i))]
end



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
Hermes Hermes
Reply | Threaded
Open this post in threaded view
|

Re: update script to Scilab 6.00

Hi, Pierre Payen
When running the script get the following error:

*--> exec('C:\Users\hermesr\Documents\Scilab
Xcos\Animations\penduleUpdated.sce', -1)
at line    44 of executed file C:\Users\hermesr\Documents\Scilab
Xcos\Animations\penduleUpdated.sce

Invalid index.
*

And the animation is frozen.

<http://mailinglists.scilab.org/file/t497622/Graphic_window_number_0.jpg>
Gracias
Hermes



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users