211MAT1301
211MAT1301
Submitted by
RAYALA VAMSI(9924008083)
V.AJAY KKUMAR REDDY(9924004092)
G.OM SAI(99240040927)
G. VINAY VENKATA MANI HARI(99240040228)
of
1 2023 – 2024
Academic Year:
KALASALINGAM ACADEMY OF RESEARCH AND EDUCATION
(DEEMED TO BE UNIVERSITY)
KRISHNANKOIL 626 126
I hereby declare that the report entitled “MAXIMUM AND MINIMUM PERCENTAGE OF ENERGY DISSOLVED
IN THE HUMAN FLUIDS WITH RESPECT TO TIME ” submitted by our team for the Degree of Bachelor of
Technology Iin CSE is the result of my original and independent research work carried out under the supervision
Education, Krishnankoil and it has not been submitted for the award of any degree, diploma,
STUDENT
REGISTER. No: STUDENT NAME
SIGNATURE
99240040927 G.OMSAI
Date:
2
KALASALINGAM ACADEMY OF RESEARCH AND EDUCATION
(DEEMED TO BE UNIVERSITY)
KRISHNANKOIL 626 126
BONAFIDE CERTIFICATE
Certified that this Report entitled “MAXIMUM AND MINIMUM PERCENT AGE OF
K UM AR RE DD Y who carried out the research under my supervision. Certified further, that to the best
of my knowledge the work reported herein does not form part of any other report or dissertation on the
basis of which a degree or award was conferred on an earlier occasion on this or any other scholar.
3
ACKNOWLEDGEMENT
4
ABSTRACT
5
LIST OF TABLES
The list should use exactly the same captions as they appear above the tables in the text. The
list should be prepared with 1.5 line spacing.
6
LIST OF FIGURES
The list should use exactly the same captions as they appear below the figures in the text. The
list should be prepared with 1.5 line spacing.
7
TABLE OF CONTENTS
8
CHAPTER 1
INTRODUCTION
MATLAB is a programming and numeric computing platform used by millions of engineers and
scientists to analyze data, develop algorithms, and create models.
1. Starting MATLAB
After logging into your account, you can enter MATLAB by double-clicking on the MATLAB
shortcut icon on your Windows desktop. When you start MATLAB, a special window called the
MATLAB desktop appears. The desktop is a window that contains other windows. The major
tools within or accessible from the desktop are:
• The WORKSPACE
• The CURRENT DIRECTORY
• The HELP BROWSER
• The START button
As an example of a simple interactive calculation, just type the expression you want to evaluate.
Let’s start at the very beginning. For example, let’s suppose you want to calculate the
expression, 1 + 2 × 3. You type it at the prompt command (>>) as follows,
>> 1+2*3
ans = 7
You will have noticed that if you do not specify an output variable, MATLAB uses a default
variable ans, short for answer, to store the results of the current calculation. Note that the
variable ans is created (or overwritten, if it is already existed). To avoid this, you may assign a
value to a variable or output argument name. For example,
>> x = 1+2*3
x=7
will result in x being given the value 1 + 2 x 3 = 7. × This variable name can always be
used to refer to the results of the previous computations. Therefore, computing 4x will result in
Quitting MATLAB
To end your MATLAB session, type quit in the Command Window, or select File →
MATLAB variables are created with an assignment statement. The syntax of variable
assignment is
10
For example,
>> x = expression
manual entry
built-in functions
user-defined functions
Overwriting variable
Once a variable has been created, it can be reassigned. In addition, if you do not wish to see the
intermediate results, you can suppress the numerical output by putting a semicolon (;) at the
end of the line. Then the sequence of commands looks like this:
>> t = 5;
>> t = t+1
t=6
Error messages
If we enter an expression incorrectly, MATLAB will return an error message. For example, in
the following, we left out the multiplication sign, *, in the following expression
>> x = 10;
>> 5x
??? 5x
|
Error: Unexpected MATLAB expression.
Making corrections
To make corrections, we can, of course retype the expressions. But if the expression is lengthy,
we make more mistakes by typing a second time. A previously typed command can be recalled
with the up-arrow key. When the comm↑and is displayed at the command prompt, it can be
modified if needed and executed.
11
Controlling the hierarchy of operations or precedence
Let’s consider the previous arithmetic operation, but now we will include parentheses. For
example, 1 + 2 × 3 will become (1 + 2) × 3
>> (1+2)*3
ans = 9
>> 1+2*3
ans = 7
MATLAB by default displays only 4 decimals in the result of the calculations, for example
163.6667, as shown in above examples. However, MATLAB does numerical calculations in
double precision, which is 15 digits. The command format controls how the results of
computations are displayed. Here are some examples of the different formats together with
the resulting outputs.
The contents of the workspace persist between the executions of separate commands. There-
fore, it is possible for the results of one problem to have an effect on the next one. To avoid this
possibility, it is a good idea to issue a clear command at the start of each new inde- pendent
calculation.
12
>> clear
The command clear or clear all removes all variables from the workspace. This frees up system
memory. In order to display a list of the variables currently in the memory, type
>> who
while, whos will give more details which include size, space allocation, and class of the
variables.
It is possible to keep track of everything done during a MATLAB session with the diary
command.
>> diary
It is possible to enter multiple statements per line. Use commas (,) or semicolons (;) to enter
more than one statement at once. Commas (,) allow multiple statements per line without
suppressing output.
b=
0.6570
c=
548.3170
13
Miscellaneous commands
Getting help
To view the online documentation, select MATLAB Help from Help menu or MATLAB Help
directly in the Command Window. The preferred method is to use the Help Browser. The Help
Browser can be started by selecting the ? icon from the desktop toolbar. On the other hand,
information about any command is available by typing
Another way to get help is to use the lookfor command. The lookfor command differs from the
help command. The help command searches for an exact function name match, while the
lookfor command searches the quick summary information in each function for a match. For
example, suppose that we were looking for a function to take the inverse of a matrix. Since
MATLAB does not have a function named inverse, the command help inverse will produce
nothing. On the other hand, the command lookfor inverse will produce detailed information,
which includes the function of interest, inv.
NOTE - At this particular time of our study, it is important to emphasize one main point. Because
MATLAB is a huge program; it is impossible to cover all the details of each function one by
one. However, we will give you information how to get help. Here are some examples:
In the current version (MATLAB version 7), the doc function opens the on-line version of the
help manual. This is very helpful for more complex commands.
MATLAB offers many predefined mathematical functions for technical computing which
contains a large set of mathematical functions.
Typing help elfun and help specfun calls up full lists of elementary and special
functions respectively.
There is a long list of mathematical functions that are built into MATLAB. These functions are
called built-ins. Many standard mathematical functions, such as sin(x), cos(x), tan(x), ex, ln(x),
are evaluated by the functions sin, cos, tan, exp, and log respectively in MATLAB.
Table 1.1 lists some commonly used functions, where variables x and y can be numbers,
vectors, or matrices.
15
Basic plotting
MATLAB has an excellent set of graphic tools. Plotting a given data set or the results of
computation is possible with very few commands. You are highly encouraged to plot
mathematical functions and results of analysis as often as possible. Trying to understand
mathematical equations with graphics is an enjoyable and very efficient way of learning math-
ematics. Being able to plot mathematical functions and data freely is the most important step,
and this section is written to assist you to do just that.
The basic MATLAB graphing procedure, for example in 2D, is to take a vector of x-
coordinates, x = (x1, . . . , xN ), and a vector of y-coordinates, y = (y1, . . . , yN ), locate the points
(xi, yi), with i = 1, 2, . . . , n and then join them by straight lines. You need to prepare x and y in
an identical array form; namely, x and y are both row arrays or column arrays of the same
length.
The MATLAB command to plot a graph is plot(x,y). The vectors x = (1, 2, 3, 4, 5, 6) and y =
(3, −1, 2, 4, 5, 1) produce the picture shown in Figure 2.1.
>> x = [1 2 3 4 5 6];
>> y = [3 -1 2 4 5 1];
>> plot(x,y)
NOTE: The plot functions have different forms depending on the input arguments. If y is a vector
plot(y) produces a piecewise linear graph of the elements of y versus the index of the elements
of y. If we specify two vectors, as mentioned above, plot(x,y) produces a graph of y versus x.
For example, to plot the function sin (x) on the interval [0, 2π], we first create a vector of x
values ranging from 0 to 2π, then compute the sine of these values, and finally plot the result:
MATLAB enables you to add axis labels and titles. For example, using the graph from the
previous example, add an x- and y-axis labels.
Now label the axes and add a title. The character \pi creates the symbol π. An example of 2D
plot is shown in Figure 1.2.
The color of a single curve is, by default, blue, but other colors are possible. The desired color
is indicated by a third argument. For example, red is selected by plot(x,y,’r’). Note the single
quotes, ’ ’, around r.
17
Multiple data sets in one plot
Multiple (x, y) pairs arguments create multiple graphs with a single call to plot. For example,
these statements plot three related functions of x: y1 = 2 cos(x), y2 = cos(x), and y3 =
0.5 ∗ cos(x), in the interval 0 ≤ x ≤ 2π.
>> x = 0:pi/100:2*pi;
>> y1 = 2*cos(x);
>> y2 = cos(x);
>> y3 = 0.5*cos(x);
>> plot(x,y1,’--’,x,y2,’-’,x,y3,’:’)
>> xlabel(’0 \leq x \leq 2\pi’)
>> ylabel(’Cosine functions’)
>> legend(’2*cos(x)’,’cos(x)’,’0.5*cos(x)’)
>> title(’Typical example of multiple plots’)
>> axis([0 2*pi -3 3])
The result of multiple data sets in one graph plot is shown in Figure 1.3.
By default, MATLAB uses line style and color to distinguish the data sets plotted in the graph.
However, you can change the appearance of these graphic components or add annotations to
the graph to help explain your data for presentation.
18
Specifying line styles and colors
It is possible to specify line styles, colors, and markers (e.g., circles, plus signs, . . . ) using the
plot command:
plot(x,y,’style_color_marker’)
Matrices are the basic elements of the MATLAB environment. A matrix is a two-dimensional
array consisting of m rows and n columns. Special cases are column vectors (n = 1) and row
vectors (m = 1).
In this section we will illustrate how to apply different operations on matrices. The following
topics are discussed: vectors and matrices in MATLAB, the inverse of a matrix, determinants,
and matrix manipulation.
MATLAB supports two types of operations, known as matrix operations and array operations.
Matrix operations will be discussed first.
Matrices are fundamental to MATLAB. Therefore, we need to become familiar with matrix
generation and manipulation. Matrices can be generated in several ways.
19
Entering a vector
A vector is a special case of a matrix. The purpose of this section is to show how to create
vectors and matrices in MATLAB. As discussed earlier, an array of dimension 1 x n is called a
row vector, whereas an array of dimension m x 1 is called a column vector. The elements of
vectors in MATLAB are enclosed by square brackets and are separated by spaces or by
commas. For example, to enter a row vector, v, type
>> v = [1 4 7 10 13]
v=
1 4 7 10 13
Column vectors are created in a similar way, however, semicolon (;) must separate the
components of a column vector,
>> w = [1;4;7;10;13]
w =
1
4
7
10
13
On the other hand, a row vector is converted to a column vector using the transpose operator.
The transpose operation is denoted by an apostrophe or a single quote (’).
>> w = v’
w=
1
4
7
10
13
Entering a matrix
>> A = [1 2 3; 4 5 6; 7 8 9]
A=
1 2 3
4 5 6
7 8 9
Note that the use of semicolons (;) here is different from their use mentioned earlier to suppress
output or to write multiple commands in a single line.
Once we have entered the matrix, it is automatically stored and remembered in the Workspace.
We can refer to it simply as matrix A. We can then view a particular element in a matrix by
specifying its location. We write,
>> A(2,1)
ans = 4
A(2,1) is an element located in the second row and first column. Its value is 4.
Matrix indexing
We select elements in a matrix just as we did for vectors, but now we need two indices. The
element of row i and column j of the matrix A is denoted by A(i,j). Thus, A(i,j) in MATLAB
refers to the element Aij of matrix A. The first index is the row number and the second index is
the column number. For example, A(1,3) is an element of first row and third column. Here,
A(1,3)=3.
Correcting any entry is easy through indexing. Here we substitute A(3,3)=9 by
A(3,3)=0. The result is
>> A(3,3) = 0
A =
1 2 3
4 5 6
7 8 0
Single elements of a matrix are accessed as A(i,j), where i ≥1 and j ≥1. Zero or negative
subscripts are not supported in MATLAB.
21
Colon operator
The colon operator will prove very useful and understanding how it works is the key to efficient
and convenient usage of MATLAB. It occurs in several different forms.
Often we must deal with matrices or vectors that are too large to enter one ele- ment at a time.
For example, suppose we want to enter a vector x consisting of points (0, 0.1, 0.2, 0.3, · · · , 5).
We can use the command
>> x = 0:0.1:5;
Linear spacing
On the other hand, there is a command to generate linearly spaced vectors: linspace. It is similar
to the colon operator (:), but gives direct control over the number of points. For example,
y = linspace(a,b)
generates a row vector y of 100 points linearly spaced between and including a and b. y =
linspace(a,b,n)
generates a row vector y of n points linearly spaced between and including a and b. This is
useful when we want to divide an interval into a number of subintervals of the same length. For
example,
divides the interval [0, 2π] into 100 equal subintervals, then creating a vector of 101 elements.
The colon operator can also be used to pick out a certain row or column. For example, the
statement A(m:n,k:l specifies rows m to n and column k to l. Subscript expressions refer to
portions of a matrix. For example,
>> A(2,:)
ans =
4 5 6
22
>> A(:,2:3)
ans =
2 3
5 6
8 0
>> A(:,2)=[ ]
ans =
1 3
4 6
7 0
Creating a sub-matrix
To extract a submatrix B consisting of rows 2 and 3 and columns 1 and 2 of the matrix A, do
the following
B=
4 5
7 8
To interchange rows 1 and 2 of A, use the vector of row indices together with the colon
operator.
It is important to note that the colon operator (:) stands for all columns or all rows. To create
a vector version of matrix A, do the following
23
>> A(:)
ans =
1
2
3
4
5
6
7
8
0
The keyword end, used in A(end,:), denotes the last index in the specified dimension. Here
are some examples.
>> A
A =
1 2 3
4 5 6
7 8 9
>> A(2:3,2:3)
ans =
5 6
8 9
24
>> A([1 3],[2 3])
ans =
2 3
8 9
>> A(3,:) = [ ]
A=
1 2 3
4 5 6
Third row of matrix A is now deleted. To restore the third row, we use a technique for
creating a matrix
Dimension
To determine the dimensions of a matrix or vector, use the command size. For example,
>> size(A)
ans =
3 3
>> [m,n]=size(A)
25
Transposing a matrix
The transpose operation is denoted by an apostrophe or a single quote (’). It flips a matrix about
its main diagonal and it turns a row vector into a column vector. Thus,
>> A’
ans =
1 4 7
2 5 8
3 6 0
Matrix generators
MATLAB provides functions that generates elementary matrices. The matrix of zeros, the
matrix of ones, and the identity matrix are returned by the function’s zeros, ones, and eye,
respectively.
Special matrices
MATLAB provides a number of special matrices (see Table 1.5). These matrices have inter-
esting properties that make them useful for constructing examples and for testing algorithms.
For more information, see MATLAB documentation.
MATLAB provides many matrix functions for various matrix/vector manipulations; see Table
1.6 for some of these functions. Use the online help of MATLAB to find how to use these
functions.
det Determinant
diag Diagonal matrices and diagonals of a matrix
eig Eigenvalues and eigenvectors
inv Matrix inverse
norm Matrix and vector norms
rank Number of linearly independent rows or columns
So far in these lab sessions, all the commands were executed in the Command Window. The
problem is that the commands entered in the Command Window cannot be saved and executed
again for several times. Therefore, a different way of executing repeatedly commands with
MATLAB is:
If needed, corrections or changes can be made to the commands in the file. The files that are
used for this purpose are called script files or scripts for short.
This section covers the following topics:
• M-File Scripts
• M-File Functions
A script file is an external file that contains a sequence of MATLAB statements. Script files
have a filename extension .m and are often called M-files. M-files can be scripts that simply
execute a series of MATLAB statements, or they can be functions that can accept arguments
and can produce one or more outputs.
There is another way to open the editor:
27
>> edit
or
to open filename.m.
Script side-effects
All variables created in a script file are added to the workspace. This may have undesirable
effects, because:
The execution of the script can be affected by the state variables in the workspace.
As a result, because scripts have some undesirable side-effects, it is better to code any
complicated applications using rather function M-file.
M-File functions
As mentioned earlier, functions are programs (or routines) that accept input arguments and
return output arguments. Each M-file function (or function or M-file for short) has its own area
of workspace, separated from the MATLAB base workspace.
f = prod(1:n); (4)
The first line of a function M-file starts with the keyword function. It gives the function name
and order of arguments. In the case of function factorial, there are up to one output argument
and one input argument. Table 4.1 summarizes the M-file function.
As an example, for n = 5, the result is,
28
>> f = factorial(5)
f=
120
Both functions and scripts can have all of these parts, except for the function definition line
which applies to function only.
In addition, it is important to note that function name must begin with a letter, and must be no
longer than than the maximum of 63 characters. Furthermore, the name of the text file that you
save will consist of the function name with the extension .m. Thus, the above example file
would be factorial.m.
Table 4.2 summarizes the differences between scripts and functions.
SCRIPTS FUNCTIONS
- Do not accept input - Can accept input arguments and
arguments or return output return output arguments.
arguments.
- Store variables in a - Store variables in a workspace internal to
workspace that is shared with the function.
other scripts
- Are useful for automating a - Are useful for extending the MATLAB
series of commands language for your application
29
Input and output arguments
As mentioned above, the input arguments are listed inside parentheses following the function
name. The output arguments are listed inside the brackets on the left side. They are used to
transfer the output from the function file. The general form looks like this
Function file can have none, one, or several output arguments. Table 4.3 illustrates some
possible combinations of input and output arguments.
When a script file is executed, the variables that are used in the calculations within the file must
have assigned values. The assignment of a value to a variable can be done in three ways.
We have already seen the two first cases. Here, we will focus our attention on the third one. In
this case, the variable is defined in the script file. When the file is executed, the user is prompted
to assign a value to the variable in the command prompt. This is done by using the input
command. Here is an example.
30
game1 = input(’Enter the points scored in the first game ’);
game2 = input(’Enter the points scored in the second game ’); game3 = input(’Enter the
points scored in the third game ’); average = (game1+game2+game3)/3
The following shows the command prompt when this script file (saved as example3) is
executed.
>> example3
>> Enter the points scored in the first game 15
>> Enter the points scored in the second game 23
>> Enter the points scored in the third game 10
average =
16
The input command can also be used to assign string to a variable. For more information, see
MATLAB documentation.
A typical example of M-file function programming can be found in a recent paper which related
to the solution of the ordinary differential equation (ODE) [12].
Output commands
As discussed before, MATLAB automatically generates a display when commands are exe-
cuted. In addition to this automatic display, MATLAB has several commands that can be used
to generate displays or outputs.
Two commands that are frequently used to generate output are: disp and fprintf. The main
differences between these two commands can be summarized as follows (Table 4.4).
31
1.1.6 Control flow operators
MATLAB has four control flow structures: the if statement, the for loop, the while loop, and
the switch statement.
if ... end
if expression statements
end
• no semicolon (;) is needed at the end of lines containing if, else, end
32
Relational and logical operators
Note that the “equal to” relational operator consists of two equal signs (==) (with no space
between them), since = is reserved for the assignment operator.
In the for ... end loop, the execution of a command is repeated at a fixed and predeter-
mined number of times. The syntax is
Usually, expression is a vector of the form i:s:j. A simple example of for loop is
for ii=1:5
x=ii*ii
end
It is a good idea to indent the loops for readability, especially when they are nested. Note that
MATLAB editor does it automatically.
Multiple for loops can be nested, in which case indentation helps to improve the readability.
The following statements form the 5-by-5 symmetric matrix A with (i, j) element i/j for j ≥ i:
33
n = 5;
A = eye(n);
for j=2:n
for i=1:j-1
A(i,j)=i/j;
A(j,i)=i/j;
end
end
This loop is used when the number of passes is not specified. The looping continues until a
stated condition is satisfied. The while loop has the form:
while expression
statements
end
x=1
while x <= 10
x = 3*x
end
It is important to note that if the condition inside the looping is not well defined, the looping
will continue indefinitely. If this happens, we can stop the execution by pressing Ctrl-C.
• The break statements. A while loop can be terminated with the break statement, which
passes control to the first statement after the corresponding end. The break statement can also
be used to exit a for loop.
• The continue statement can also be used to exit a for loop to pass immediately to the
next iteration of the loop, skipping the remaining statements in the loop.
• Other control statements include return, continue, switch, etc. For more detail about
these commands, consul MATLAB documentation.
34
Operator precedence
We can build expressions that use any combination of arithmetic, relational, and logical
operators. Precedence rules determine the order in which MATLAB evaluates an expression.
We have already seen this in the “Tutorial Lessons”.
Here we add other operators in the list. The precedence rules for MATLAB are shown in this
list (Table), ordered from highest (1) to lowest (9) precedence level. Operators are evaluated
from left to right.
1 Parentheses
2 Transpose (. '), power (.ˆ), matrix power (ˆ)
3
4
5
6
7
In addition to displaying output on the screen, the command fprintf can be used for writing the
output to a file. The saved data can subsequently be used by MATLAB or other softwares.
To save the results of some computation to a file in a text format requires the following steps:
35
CHAPTER 2
36
Manufacturing Data of the Tablet Formulation
Process : The manufacturing process involves
blending active pharmaceutical ingredients (APIs)
with excipients, granulating the mixture,
compressing it into tablets, and coating them (if
needed).Ingredients: Active ingredient, binders,
disintegrants, lubricants, and coating agents.Steps:1
37
Chemical Composition Active Pharmaceutical Ingredient
(API): The primary compound responsible for the
therapeutic effect.Excipients:1. Binders: Ensure the tablet
holds its shape (e.g., Povidone, Starch).2. Disintegrants:
Help the tablet break apart upon ingestion (e.g., Sodium
starch glycolate).3. Lubricants: Reduce friction during
production (e.g., Magnesium stearate).4. Coating Agents:
Protect the tablet and control release (e.g., Hydroxypropyl
methylcellulose).
Weighing and Mixing: The raw materials are
accurately weighed and homogeneously
mixed.2. Granulation: The mixture is
granulated to ensure uniformity.3.
Compression: The granules are compressed
into tablets using a tablet press.4. Coating:
Tablets may be coated to control release
rates or protect the active ingredient.
CHAPTER 3
1
CHAPTER 4