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

« back to all changes in this revision

Viewing changes to demos/misc/oscil.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [yd]=fty(t,y)
 
2
//
 
3
//  RHS of Differential equation
 
4
//
 
5
en = ener(t)
 
6
if y(1)<0 then
 
7
  if en<.5 then
 
8
    yd(1) = 0;
 
9
  else
 
10
    yd(1) = l.*(e-r*y(2));
 
11
  end;
 
12
  yd(2)=-y(2)/(r*c);
 
13
else
 
14
  yd(1)=l*(e*en-y(2)*r);
 
15
  yd(2)=(y(1)-y(2))/(r*c);
 
16
end;
 
17
 
 
18
function [en]=ener(t)
 
19
//
 
20
// Energy
 
21
//
 
22
t1=t-pe1*int(t/pe1);
 
23
if t1>pe2 then en=0; else en=1; end;
 
24
 
 
25
function [en]=ene1(t,pe1,pe2)
 
26
t1=t-pe1*int(t/pe1)
 
27
en=round( ones(t1)-t1/pe1 + (.5-(1.-pe2/pe1))*ones(t1) )
 
28
 
 
29
function [en]=ene2(t,pe1,pe2)
 
30
t1=t/pe1-int(t/pe1)
 
31
en=round( ones(t1)-t1 + (.5-(1-pe2/pe1))*ones(t1) )
 
32
 
 
33
function [en]=ene3(t,pe1,pe2)
 
34
en=round( ones(t)-t/pe1+int(t/pe1) + (.5-(1-pe2/pe1))*ones(t) )
 
35