diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /845/CH11 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '845/CH11')
-rwxr-xr-x | 845/CH11/EX11.1/Ex11_1.sce | 41 | ||||
-rwxr-xr-x | 845/CH11/EX11.2/Ex11_2.sce | 29 |
2 files changed, 70 insertions, 0 deletions
diff --git a/845/CH11/EX11.1/Ex11_1.sce b/845/CH11/EX11.1/Ex11_1.sce new file mode 100755 index 000000000..772dbb3fe --- /dev/null +++ b/845/CH11/EX11.1/Ex11_1.sce @@ -0,0 +1,41 @@ +//Example 11.1
+
+clc
+clear
+
+delx = 1/8;
+delt = 1/8;
+x = 0:delx:1;
+t = 0:delt:1;
+m = length(x);
+n = length(t);
+u =zeros(n,m);
+u(1,:) = sin(%pi*x);
+N = 1/delx;
+r = delt/delx;
+
+for j = 2:n
+ for i = 2:m-1
+ if j == 2 then
+ u(j,i) = (2*(1-r^2)*u(j-1,i) + r^2*(u(j-1,i-1) + u(j-1,i+1))) /2;
+ else
+ u(j,i) = 2*(1-r^2)*u(j-1,i) + r^2*(u(j-1,i-1) + u(j-1,i+1)) - u(j-2,i);
+ end
+ end
+end
+u = round(u*10^4)/10^4;
+mprintf("\n\n%6s %9s %9s %8s %s %8s %10s %10s %9s %7s %s",'t','x = 0.0','x = 0.125','x = 0.25','x = 0.375','x = 0.5','x=0.625','x = 0.75','x=0.875','x = 1.0','n');
+disp([(0:1/8:1)' u (0:n-1)']);
+mprintf("\n\n");
+t = [1/2 1];
+for i = 1:length(t)
+ Ex(i,:) = sin(%pi*x) * cos(%pi*t(i));
+end
+Ex = round(Ex*10^4)/10^4;
+disp("At t = 1/2:")
+disp(u(find(x==1/2),:),"Computed Solution:")
+disp(Ex(1,:),"Actual Solution:")
+
+disp("At t = 1:")
+disp(u(find(x==1),:),"Computed Solution:")
+disp(Ex(2,:),"Actual Solution:")
diff --git a/845/CH11/EX11.2/Ex11_2.sce b/845/CH11/EX11.2/Ex11_2.sce new file mode 100755 index 000000000..ec8b8db21 --- /dev/null +++ b/845/CH11/EX11.2/Ex11_2.sce @@ -0,0 +1,29 @@ +//Example 11.2
+
+clc
+clear
+
+delx = 0.2;
+delt = 0.2;
+x = 0:delx:1;
+t = 0:delt:0.8;
+m = length(x);
+n = length(t);
+u =zeros(n,m);
+u(1,:) = x^2;
+u(:,m) = 1+t';
+N = 1/delx;
+r = delt/delx;
+
+for j = 2:n
+ for i = 2:m-1
+ if j == 2 then
+ u(j,i) = (2*(1-r^2)*u(j-1,i) + r^2*(u(j-1,i-1) + u(j-1,i+1)) + 2*delt) /2;
+ else
+ u(j,i) = 2*(1-r^2)*u(j-1,i) + r^2*(u(j-1,i-1) + u(j-1,i+1)) - u(j-2,i);
+ end
+ end
+end
+u = round(u*10^4)/10^4;
+mprintf("\n%5s %9s %7s %7s %s %6s %6s",'t','x = 0.0','x = 0.2','x = 0.4','x = 0.6','x = 0.8','x = 1.0');
+disp([t' u])
|