summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tutorial4_ODE/Scilab_code/Tutorial4_ode_matrix.sce19
-rw-r--r--Tutorial4_ODE/Scilab_code/Tutorial4_ode_simple.sce19
-rw-r--r--Tutorial4_ODE/Scilab_code/Tutorial4_ode_simple_plot.sce19
-rw-r--r--Tutorial5_Nonlinear_equation/Scilab_code/Tutotial5_nonlinear_equation.sce6
-rw-r--r--Tutorial5_Nonlinear_equation/Scilab_code/func.sci4
5 files changed, 63 insertions, 4 deletions
diff --git a/Tutorial4_ODE/Scilab_code/Tutorial4_ode_matrix.sce b/Tutorial4_ODE/Scilab_code/Tutorial4_ode_matrix.sce
new file mode 100644
index 0000000..fff34eb
--- /dev/null
+++ b/Tutorial4_ODE/Scilab_code/Tutorial4_ode_matrix.sce
@@ -0,0 +1,19 @@
+//This script demonstrates the use of ODE solver when matrix is involved
+
+//Definition of the function
+function ydot = func(t,y)
+ ydot = A*y + ones(3,1);
+endfunction
+
+//Defining the matrix
+A = [1 2 1;9 6 1;1 3 4];
+//Initial condition
+y0 = [-1;2;3];
+//Start time
+t0= 0;
+//The time at which the solution is computed
+t = 0.2;
+//Calling the ode solver
+sol=ode(y0,t0,t,func);
+//Displaying the solution
+disp(sol,"y(t) at t = 0.2");
diff --git a/Tutorial4_ODE/Scilab_code/Tutorial4_ode_simple.sce b/Tutorial4_ODE/Scilab_code/Tutorial4_ode_simple.sce
new file mode 100644
index 0000000..ad42d4d
--- /dev/null
+++ b/Tutorial4_ODE/Scilab_code/Tutorial4_ode_simple.sce
@@ -0,0 +1,19 @@
+//This script demonstrates the use of ODE solver
+
+//Definition the function.
+//The function is dy/dt = cos(t)*sin(t) - tan(t) + 1
+function ydot = func(t,y)
+ ydot = cos(t)*sin(t) - tan(t) + 1
+endfunction
+
+//Initial condition of the problem, a scalar or vector
+y0 = -1;
+//Initial time, a real scalar
+t0= 0;
+//The time at which the solution is computed
+t = 0.2;
+//Calling the ode solver
+sol=ode(y0,t0,t,func);
+//Displaying the solution
+disp(sol,"y(t) at t = 0.2");
+
diff --git a/Tutorial4_ODE/Scilab_code/Tutorial4_ode_simple_plot.sce b/Tutorial4_ODE/Scilab_code/Tutorial4_ode_simple_plot.sce
new file mode 100644
index 0000000..4ecf87e
--- /dev/null
+++ b/Tutorial4_ODE/Scilab_code/Tutorial4_ode_simple_plot.sce
@@ -0,0 +1,19 @@
+//This script demonstrates the use of ODE solver and computing the
+//solution at different times. The output is in the form of a plot
+//of time versus computed solution
+
+//Definition the function.
+function ydot = func(t,y)
+ ydot = t^2*exp(-2*t) + y
+endfunction
+
+//Initial condition
+y0 = -1;
+//Start time
+t0= 0;
+//The array of time where the solution is computed
+t = 4:0.01:10;
+//Calling the ODE solver
+sol=ode(y0,t0,t,func);
+//Plotting the result
+plot(t,sol)
diff --git a/Tutorial5_Nonlinear_equation/Scilab_code/Tutotial5_nonlinear_equation.sce b/Tutorial5_Nonlinear_equation/Scilab_code/Tutotial5_nonlinear_equation.sce
index 6d38c84..5da2894 100644
--- a/Tutorial5_Nonlinear_equation/Scilab_code/Tutotial5_nonlinear_equation.sce
+++ b/Tutorial5_Nonlinear_equation/Scilab_code/Tutotial5_nonlinear_equation.sce
@@ -5,16 +5,14 @@ clc
//The nonlinear equation for which solutions are sought
-function y = nonlinear_func(x)
- y = cos(x)*sin(x) - tan(x) + 1
-endfunction
+exec func.sci;
//Initial guess for the solution
x0 = 0;
//Computation of solution using fsolve
-y_result = fsolve(x0,nonlinear_func);
+y_result = fsolve(x0,func);
//Display the solution in command window
disp(y_result,'Solution of the equation')
diff --git a/Tutorial5_Nonlinear_equation/Scilab_code/func.sci b/Tutorial5_Nonlinear_equation/Scilab_code/func.sci
new file mode 100644
index 0000000..91b9fcc
--- /dev/null
+++ b/Tutorial5_Nonlinear_equation/Scilab_code/func.sci
@@ -0,0 +1,4 @@
+//This is script to define a fuction
+function y = func(x)
+ y = cos(x)*sin(x) - tan(x) + 1
+endfunction