Posts

Showing posts from December, 2020

MATLAB Tutorials class 5: MATLAB inbuild command repmat,repelem,cat,horzcat, and vertcat

MATLAB Tutorials class 5: MATLAB inbuild command repmat,repelem, cat,horzcat, and vertcat           We discussed MATLAB inbuild command diag,det, and trace in my previous post . We're going to see repmat, repelem, cat,horzcat, and vertcat MATLAB commands and their functions in this post.  repmat   repmat command used to repeat the copies of the array. Syntax is repmat_value=repmat(array,no)  How to create a matrix in which all elements should be the same in MATLAB? >> repmat_value=repmat(10,4) repmat_value =     10    10    10    10     10    10    10    10     10    10    10    10     10    10    10    10 >> repmat_value=repmat(10,4,3) repmat_value =     10    10    10     10    10    10     10    10    10     10    10    10 How to repeat one matrix in square shape and rectangle shape? >> rand_matrix_creation=randi(2,3) rand_matrix_creation =      2     1     1      1     1     2      1     2     2 >> repmat_value=repmat(rand_matrix_creation,2,2) repmat_val

MATLAB Tutorials class 4 : MATLAB command diag, det, trace

MATLAB Tutorials class 4: MATLAB command  diag, det, trace               We discussed random number generation in my previous post (rand, randi,randn function). We're going to see some interesting Matlab commands and their functions in this post. They are diag,det, and trace. First, we going to see about diag diag           By using the diag command we can create a diagonal matrix and can compute the diagonal of the matrix. Diagonal elements are one in the identity matrix(eye), but we can create our desired diagonal element by using the diag command. This is the major difference between the diagonal matrix (diag) and the identity matrix (eye). 1. How to create a diagonal matrix in MATLAB?           The syntax for creating a diagonal matrix in MATLAB is                 diag_creation=diag([1 2 3 4 5]) >> diag_creation=diag([1 2 3 4 5]) diag_creation =      1     0     0     0     0      0     2     0     0     0      0     0     3     0     0      0     0     0     4     0  

MATLAB Tutorials Class3 : How to Generate random number in MATLAB

MATLAB Tutorials Class3: How to Generate a  random number in MATLAB Hai... We addressed the creation of an array and matrix in my previous post . We will see how to generate a random number in MATLAB here.  1. How to generate uniformly distributed random numbers in MATLAB? Syntax is                           rand_val_creation=rand() The uniformly distributed number 0 to 1 range is generated by the rand function. We can create a random matrix, just like the creation of zeros and one's matrix.  Case 1:if we give syntax like 'rand' means it creates 1 x 1 rand matrix range between 0 to 1. >> rand_no_creation=rand rand_no_creation =     0.8147 Case 2: If we mention a number, that number is considered to be a row and column count. >> rand_no_creation=rand(4) rand_no_creation =     0.9058    0.0975    0.9649    0.4854     0.1270    0.2785    0.1576    0.8003     0.9134    0.5469    0.9706    0.1419     0.6324    0.9575    0.9572    0.4218 Case 3: if suppose we need a s

MATLAB Tutorials Class 2: Creation of Matrix and array in MATLAB

 MATLAB Tutorials Class 2:  Creation of  Matrix and array in  MATLAB  Hai... We addressed the environmental setup and layout configuration in my previous post . Here we going to see Matrix and array. The expansion of MATLAB is the 'Matrix laboratory'. MATLAB script operations are based on matrix and array. 1. What is the Matrix?           The matrix is a framework for the number of columns and rows. The matrix may look rectangular or square. A count of rows and columns is used for matrix status representation ( no. of. row X no. of. column matrix). For instance, if the number of rows and columns is 3, the matrix is known as the 3 x 3 matrix.  2. What is an array?          An array is an arrangement of elements together in a single row.   3. How to create an  array  in MATLAB? To do this, you can use the command window. For execution, after entering the code line, give enter. If you want to see the answer in the same command window means, you don't put the semicolon at last.

MATLAB tutorials class 1 : Environmental setup and layout configuration in MATLAB

Image
  MATLAB tutorials class 1: Environmental setup and layout configuration in MATLAB                Hai... We are going to discuss the environmental setup in MATLAB in this post. We need to know who invented the MATLAB tool before going to see the basics first. He's Cleve Moler. In 1981, MATLAB was originally designed by Cleve Moler as a calculator function with 71 reserved commands. Matlab wasn't used as a programming language at that time. TABLE 1 represents that 71 reserved command. Table 1. Reserved command for MATLAB version 1981 ABS ATAN BASE CHAR CHOP CHOP COND CONJ COS DET DIAG DIAR DISP EIG EPS EXEC EXP EYE FLOP HESS HILB IMAG INV ORTH LINE LOAD LOG LU MAGI NORM ONES RANK