diff options
Diffstat (limited to '1332/CH19/EX19.4/19_4.sce')
-rwxr-xr-x | 1332/CH19/EX19.4/19_4.sce | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/1332/CH19/EX19.4/19_4.sce b/1332/CH19/EX19.4/19_4.sce new file mode 100755 index 000000000..fccff750e --- /dev/null +++ b/1332/CH19/EX19.4/19_4.sce @@ -0,0 +1,29 @@ +//Example 19.4
+//Simple Implicit Method
+//Page no. 659
+clc;clear;close;
+
+c=-2;dt=0.07;dx=0.2;
+r=abs(c)*dt/dx;
+printf('\n x\ti\t|\tj -->\t')
+for i=0:6
+ printf(' %i\t',i)
+end
+printf('\n |\t|\t|\tt -->\t')
+for i=0:6
+ printf('%.3f\t',i*dt)
+end
+printf('\n---------------------------------------------------------------------------------------')
+for j=1:6
+ printf('\n %.1f\t%i\t|\t\t',(j-1)*dx,j-1)
+ for i=1:7
+ if i==1 then
+ u(j,i)=0;
+ elseif j==1 then
+ u(j,i)=1
+ else
+ u(j,i)=(1/(1+r))*u(j,i-1)+r*u(j-1,i)/(1+r)
+ end
+ printf('%.3f\t',u(j,i))
+ end
+end
\ No newline at end of file |