summaryrefslogtreecommitdiff
path: root/27/CH5/EX5.1.1/Example_5_1_1.sce
diff options
context:
space:
mode:
Diffstat (limited to '27/CH5/EX5.1.1/Example_5_1_1.sce')
-rwxr-xr-x27/CH5/EX5.1.1/Example_5_1_1.sce55
1 files changed, 55 insertions, 0 deletions
diff --git a/27/CH5/EX5.1.1/Example_5_1_1.sce b/27/CH5/EX5.1.1/Example_5_1_1.sce
new file mode 100755
index 000000000..fdd657401
--- /dev/null
+++ b/27/CH5/EX5.1.1/Example_5_1_1.sce
@@ -0,0 +1,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