~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to demos/dae/pendg2.sce

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright INRIA
2
 
 
3
 
//
4
 
// Sliding pendulum, curve #2
5
 
//
6
 
 
7
 
mode(1)
8
 
 
9
 
getf("SCI/demos/dae/pendg.sci")
10
 
getf("SCI/demos/dae/pendc2.sci")
11
 
 
12
 
omega=3.3;
13
 
g=10; l=1; m=1; M=1; k=0.5;
14
 
x0=[1;1+cos(omega)/3;0]; u0=[0;0;0];
15
 
y0=[x0;u0;0];
16
 
ud0=[0;-g;0]; yd0=[u0;ud0;0];
17
 
 
18
 
t0=0; T=t0:0.05:20;
19
 
 
20
 
info=list([],0,[],[],[],0,0);
21
 
atol=[0.0001;0.0001;0.0001;0.0001;0.0001;0.0001;0.001];
22
 
rtol=atol;
23
 
 
24
 
sol=dassl([y0,yd0],t0,T,rtol,atol,pendg,info);
25
 
 
26
 
x=sol(2,:); y=sol(3,:); teta=sol(4,:); n=size(x,"*");
27
 
r=0.05;
28
 
xp=x+l*sin(teta); yp=y-l*cos(teta);
29
 
xp1=x+(l-r)*sin(teta); yp1=y-(l-r)*cos(teta);
30
 
 
31
 
xbasc()
32
 
xset("pixmap",1)
33
 
 
34
 
xmin=-1.5; xmax=1.5; ymin=-1.1; ymax=0.9;
35
 
vx=[xmin:0.01:xmax]'; vy=vx.*vx+cos(omega*vx)/3;
36
 
plot2d(vx,vy,5,"032"," ",[xmin,ymin,xmax,ymax])
37
 
xset("wshow")
38
 
 
39
 
xset("alufunction",6); driver("X11")
40
 
xset("thickness",2)
41
 
for i=1:n
42
 
  plot2d([x(i);xp1(i)],[y(i);yp1(i)],1,"000")
43
 
  xfarc(xp(i)-r,yp(i)+r,2*r,2*r,0,360*64)
44
 
  xset("wshow")
45
 
  xpause(30000)
46
 
  plot2d([x(i);xp1(i)],[y(i);yp1(i)],1,"000")
47
 
  xfarc(xp(i)-r,yp(i)+r,2*r,2*r,0,360*64)
48
 
  ifin=i;
49
 
end
50
 
xset("alufunction",1); driver("Rec")
51
 
plot2d([x(ifin);xp(ifin)],[y(ifin);yp(ifin)],1,"000")
52
 
xfarc(xp(ifin)-r,yp(ifin)+r,2*r,2*r,0,360*64)
53
 
xset("wshow")
54
 
 
55
 
xset("pixmap",0)
56
 
xset("default")