summaryrefslogtreecommitdiff
path: root/260/CH15/EX15.3/15_3.sce
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /260/CH15/EX15.3/15_3.sce
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '260/CH15/EX15.3/15_3.sce')
-rw-r--r--260/CH15/EX15.3/15_3.sce39
1 files changed, 39 insertions, 0 deletions
diff --git a/260/CH15/EX15.3/15_3.sce b/260/CH15/EX15.3/15_3.sce
new file mode 100644
index 000000000..48da6eae9
--- /dev/null
+++ b/260/CH15/EX15.3/15_3.sce
@@ -0,0 +1,39 @@
+//Eg-15.3
+//pg-611
+
+clear
+clc
+
+// The value of y can be computed using the equation :
+// y(i,j+1) = 0.68*y(i,j) + 0.16*y(i+1,j) + 0.16*y(i-1,j)
+y = zeros(5,5);
+y(1,1:5) = 25;
+y(1:5,1) = 100;
+y(1:5,5) = 100;
+
+//disp(y)
+
+for(j = 2:4)
+ for(i = 1:4)
+ y(i+1,j) = 0.68*y(i,j) + 0.16*y(i,j+1) + 0.16*y(i,j-1);
+ end
+
+end
+
+printf('The values of y for different t are shown in the table(Rows represents different time level and columns represent x0,x1,x2,x3,x4) below and the plot corresponding to this value is shown in the figure generated\n')
+disp(y)
+
+//There is a mistake in the textbook
+
+x = 0:0.25:1;
+
+y1 = y(1,1:5);
+y2 = y(2,1:5);
+y3 = y(3,1:5);
+y4 = y(4,1:5);
+y5 = y(5,1:5);
+
+plot(x,y1,x,y2,x,y3,x,y4,x,y5)
+legend('t0','t1','t2','t3','t4')
+xlabel('x')
+ylabel('y')