Wednesday 19 December 2018

How to find determinant and transpose of a matrix using SCILAB ?

Consider a matrix A,

1. Transpose of a matrix : If the rows and columns of the matrix are interchanged then resulting matrix is called the transpose of a given matrix.

If a matrix is having M rows and N columns then the transpose of a matrix will have N rows and M columns.

syntax : (Name of the matrix)'

Example : A' or (A)'



1. Determinant of a matrix : It is possible to find out determinant of the matrix if it is square matrix only.

syntax : det(A)



NOTE : If the matrix is not a square matrix, then the following error will be shown :
det: Wrong type for input argument #1: Square matrix expected.





Arithmetic operations between two matrices.

As we can do different arithmetic operations between numbers, same way we can also perform arithmetic operations between matrices also.

Here are some arithmetic operations :

Consider two matrices, A & B.



1. Addition :

syntax : A + B



2. Subtraction :

syntax : A - B



3. Multiplication :

syntax : A * B



NOTE :

1. For addition and subtraction of two matrices, order of two matrices should be same. i e, the number of rows and number of columns of both matrices should be same.

2. For multiplication of two matrices, the number of columns of first matrix should be equal to number of rows of second matrix.

How to find the inverse of a matrix in SCILAB ?

Note : To find out inverse of a matrix, determinant of matrix should be non-zero, that is matrix should be non-singular.

(A matrix is said to be singular, if it's determinant is zero.)

syntax to  find the inverse of any matrix,

inv(Name of the matrix) 


Consider a matrix A;
For inverse of matrix A to be possible, |A| ≠ 0;

syntax to  find the inverse of A,

inv(A) 

Example

1. |A|=0



2. |A| ≠ 0





Monday 17 December 2018

How to define and initialize a Matrix in SCILAB

whenever you have to store more than one value in a very definite manner, you can use matrices. In SCILAB also, you can store value of variable in matrix.

While defining the matrices, one can assign values to each of the variables initially.

For defining the matrix,
syntax : Name of the matrix=(M,N)
             where, M and N are orders of matrix
                       
Here, we have not defined initial value to the matrix elements.

If you want to define initial value to matrix elements, you can use following syntax.
syntax : Name of the matrix=🔺(M,N)
             where, 🔺 depends on initial value


1. If all the elements are zero, then
                                                 Name of the matrix=zeros(M,N)
example : A=zeros(5,5)



2. If all the elements are one, then
                                                Name of the matrix=ones(M,N)
example : A=zeros(5,5)



3. If all the elements are other than zero and one, let us say k, then
                                                 Name of the matrix=k*ones(M,N)
example : A=3*ones(5,5)



3. If the matrix is identity matrix, then
                                                 Name of the matrix=eye(M,N)
example : A=eye(5,5)


SCILAB TUTORIAL || 1D steady state heat conduction in a slab

Consider a 1D heat conduction through a plane slab of thickness 'L'. Both the end walls are maintained at a constant temperatures of T1 and T2. There is no heat generation inside the slab.
Let's see how is the temperature distribution inside the slab with the help of SCILAB...


SCILAB CODE :

      clc()
      L=input("Enter the thickness of the slab (in m)                 :")
      K=input("Enter the thermal conductivity of material (in W/mK)   :")
      T1=input("Enter the left wall temperature (in degree C)         :")
      T2=input("Enter the right wall temperature (in degree C)         :")
      N=input("Enter the numbaer of divisions                         :")
      n=input("Enter the number of iterations                         :")
      dx=L/N

      T=zeros(N+1)
      T(1)=T1
      T(N+1)=T2

      for k=1:1:n
          for i=2:1:N
              T(i)=(T(i+1)+T(i-1))/2
          end
      end

      x=[0:dx:L]

      //***PLOTTING THE GRAPH***//
      plot2d(x,T)


Consider :
          
          L=0.1m
          N=10
          K=237 W/mK
          n=100
          T1=150
          T2=50

Result :

Conclusion :

Temperature inside the slab varies linearly with the space.

Friday 14 December 2018

How to plot multiple 2D graph in MATLAB ?

In the previous post, we have seen what are the steps to plot a 2D graph in MATLAB. Now let's see how to plot multiple 2D graphs by an example...

EXAMPLE :
Plot graphs of sinx and cosx from 0 to 2𝝿 on a single page using MATLAB.

solution :
 
    x=linspace(0,2*pi,50);
    y1=sin(x);
    y2=cos(x);
    plot(x,y1,x,y2)




Thursday 13 December 2018

How to plot 2d graph in MATLAB ?

Steps :

     1. Define the range of  independent variable with number of divisions. 
    2. Define the function.
    3. Use the syntax to plot the graph. 


Syntax :

     plot(independent variable, function)

Example :
    Plot the graph of sin(x) from 0 to 2ℼ with 50 equal divisions of x.

    solution :
    
    step 1 : Define the variable x from 0 to 2ℼ with 50 equal divisions.
                  x=linspace(0,2*pi,50);

    step 2 : Define y=sinx
                  y=sin(x);

    step 3 : Use the syntax.
                  plot(x,y)





You can find detailed explanation from below video :

           

Logical operators in SCILAB

Logical operators :

Logical operators are used to check conditions before the operation is being performed. 

*For example, you want to display word "Hello", when variable 'a' is less than 5 and variable 'b' is greater than 3,
                        
                        so you can simply write

                        if a>5 & b>3 then
                           disp("Hello")
                        end  

likewise all other operators can be used according to the need, that we will see in next tutorials.

Some commonly used logical operators are shown below :

For detailed explanation, you can watch below video :

Conditional operators in SCILAB

Conditional operators :

Conditional operators are used to break the loop of solution. 

*For example, you want to display word "Hello", when variable 'a' is less than 5,
                        so you can simply write

                        if a>5 then
                           disp("Hello")
                        end  

likewise all other operators can be used according to the need, that we will see in next tutorials.

Some commonly used conditional operators are shown below :

For detailed explanation, you can watch below video :

Wednesday 12 December 2018

SCILAB TUTORIAL || Temperature distribution within a 2D plate subjected to constant temperatures at four walls

           ➤DIAGRAM :

           BOUNDARY CONDITIONS :

Left wall                                                       :  Any temperature (℃)
Bottom wall                                                 :  Any temperature (℃)
Right wall                                                     :  Any temperature (℃)
Top wall                                                        :  Any temperature (℃)

SCILAB CODE :

                    clc
                    disp("********2D CONSTANT WALL TEMPERATURE PROBLEM********")

                    disp("GEOMETRIC DETAILS")
                    L=input("Domain Length (in m):")
                    H=input("Domain Height (in m):")

                    disp("GRID DETAILS")
                    Nx=input("No. of divisions in X direction   :")
                    Ny=input("No. of divisions in Y direction   :")

                    dx=L/Nx
                    dy=H/Ny
                    m=(dx/dy)

                    disp("DOMAIN PROPERTIES")
                    K=input("Enter the thermal conductivity of plate material (in W/mK) :")

                    disp("BOUNDARY CONDITIONS")
                    Tl=input("Enter the left wall temperature (in Degree C)          :")
                    Tb=input("Enter the bottom wall temperature (in Degree C)        :")
                    Tr=input("Enter the right wall temperature (in Degree C)         :")
                    Tt=input("Enter the top wall temperature (in Degree C)           :")
                    Ta=input("Enter the ambient temperature (in Degree C)            :")

                    n=input("Enter the number of iterations                   :")

                    //***INITIAL TEMPERATURE OF DOMAIN***//
                    T=Ta*ones(Nx+1,Ny+1)

                    //***LEFT WALL TEMPERATURE***//
                   for j=2:1:Ny
                      T(1,j)=Tl
                   end

                   //***LEFT BOTTOM TEMPERATURE***// 
                  for i=2:1:Nx
                     T(i,1)=Tb
                  end

                  //***LEFT RIGHT TEMPERATURE***//
                 for j=2:1:Ny
                    T(Nx+1,j)=Tr
                 end

                 //***LEFT TOP TEMPERATURE***//
                 for i=2:1:Nx
                    T(i,Ny+1)=Tt
                 end

                 //***CORNER POINT TEMPERATURES***//
                T(1,1)=(Tl+Tb)/2
                T(Nx+1,1)=(Tr+Tb)/2
                T(Nx+1,Ny+1)=(Tr+Tt)/2
                T(1,Ny+1)=(Tl+Tt)/2

                 //***TEMPERATURE DISTRIBUTION IN INTERIOR POINTS***//
                for k=1:1:n
                   for j=2:1:Ny
                      for i=2:1:Nx
                         T(i,j)=(T(i+1,j)+T(i-1,j)+(m^2)*(T(i,j+1)+T(i,j-1)))/(2*(1+m^2))
                      end
                   end
                end

                //***PLOTTING CONTOUR FOR TEMPERATURE DISTRIBUTION***//
               Tmax=0
               Tmin=0
               xp=0:dx:L
               yp=0:dy:H
               for j=1:1:Ny+1
                  for i=1:1:Nx+1
                     if T(i,j)<Tmin then
                        Tmin=T(i,j)
                     end
                     if T(i,j)>Tmax then
                        Tmax=T(i,j)
                     end
                  end
               end

               clf()
               f=gcf();
               f.color_map=jetcolormap(64);
               colorbar(Tmin,Tmax)
               Sgrayplot(xp,yp,T,strf="041")

              //***TEMPERATURE DISTRIBUTION AT HORIZONTAL MID LINE***//
              xset('window',1)
              plot2d(xp,T(:,(Ny/2)+1))

              //***TEMPERATURE DISTRIBUTION AT VERTICAL MID LINE***//
              xset('window',2)
              plot2d(yp,T((Nx/2)+1,:))
              disp(T)

              //***END***//


          CONSIDER :
          
          No. of divisions in x & y directions : 100
          Thermal conductivity of plate material : 237 W/mK
          No. of iterations : 1000

         RESULT :
         
         For Tl=100
               Tb=Tr=Tt=25


Tuesday 11 December 2018

Arithmatic operators in SCILAB

Operators are mainly classified as: 1. Arithmetic operators
                                                                2. Conditional operators
                                                                3. Logical operators 

Arithmetic operators :

Arithmetic operators are used to perform various arithmetic operations between two or more variables. 

Some commonly used arithmetic variables are shown below :

For detailed explanation, you can watch below video :

          

Pre-defined variables in SCILAB

Variables are mainly classified as : 1. Pre-defined variables
                                                               2. User defined variables

Pre-defined variables :

Pre-defined variables are the variables which are defined by the software itself, so one need not to define those variables.

The values are assigned to these pre-defined variables and you have to directly call these variables while making the code.

Some of the pre-defined variables are given below : 


For detailed explanation, you can watch this video :

             

System requirements for SCILAB



1.OS (Operating System):
     
  • Windows 7/8/8.1/10 (32 and 64 bits)
  • GNU/Linux (32 and 64 bits)
  • Mac

2. Hardware :

  • 2 GB RAM (1 GB minimum)
  • 550 MB hard disk space


*In case of Mac OS java 8 is needed.

*Optional :
  • An Internet connection for ATOMS modules install (using a proxy requires manual configuration of ATOMS)
  • A C compiler (gcc/clang) for C or C++ external modules compilation and for Modelica use in Xcos
  • A Fortran compiler (gfortran) for Fortran external modules compilation

Monday 3 December 2018

How to install ANSYS ?

Hello everyone,

Here we will see, how to install  ANSYS  on windows 8/8.1/10 step by step.

So now, let us begin it.


             

How to download and install EES (Engineering Equation Solver) on windows?

Hello everyone, let us see how to download and install Engineering Equation Solver on windows?


             

How to download and install GNU plot ?

Hello everyone,
In this video we will see how to download and install GNU plot on windows platform.

Let's start...


             

How to install MATLAB on windows ?

Hello everyone,

Here we will see, how to install MATLAB on windows 8/8.1/10 step by step.

So now, let us begin it.