summaryrefslogtreecommitdiff
path: root/27/CH5/EX5.1.1/Example_5_1_1.sce
blob: fdd65740144d6f2497a84de756a1c63ad67d0f1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
clear;
clc;
close;
set(gca(),"auto_clear","off")        //hold on

circle([0 0],4,50)     //Circle is drawn with (0,0)as center, radius=4.
circle([0,0],2,50)

a=get("current_axes");        //get the handle of the newly created axes
a.data_bounds=[-5,-5;5,5];

for x = -4:2:4
    for v = -4:2:4
        if(x==0) & (v==0)
            plot2d(x,v,style=-4)        //if x=0 and v=0 then x(dot)and v(d                                        ot) are also zero, thus Fixed point.
        end
        if(x==0) & (v>0)
            plot2d(x,v,style=-12)
        end
        if(x==0) & (v<0)
            plot2d(x,v,style=-13)
        end
        if(v==0) & (x>0)
            plot2d(x,v,style=-7)
        end
        if(v==0) & (x<0)
            plot2d(x,v,style=-6)
        end
    end
end

a=get("current_axes");            //get the handle of the newly created axes
a.data_bounds=[-5,-5;5,5];
xtitle("Vector Field","X - Axis ( X )","Y - Axis ( V )")
    set(gca(),"grid",[2,5])        //Grid on

figure
function xd=linear511(t,x)
    xd(1)=x(2);                 //x(dot);   x(2) means v.
    xd(2)=-50*x(1);             //v(dot);   x(1) means x.; Taking w^2=50;
  endfunction
  bound=[-4,-4,4,4];        //Bounds of x-axis and y-axis as [xmin ymin xma                            x ymax], change them according to your needs.
  nrect=15;                 //increase it to get more number of curves, i.e                            . more information will be available.
  set(gca(),"auto_clear","off")        //hold on
  x=linspace(bound(1),bound(3),nrect);
  y=linspace(bound(2),bound(4),nrect);
  x0=[];
 
 for i=1:15
     x0=[x(i);y(i)];
     t0=0;
     t=0:0.01:3000;
     xout=ode(x0,t0,t,linear511);
     plot2d(xout(1,:),xout(2,:));
 end