0% found this document useful (0 votes)
2 views

211MAT1301

The document presents a project report on the maximum and minimum percentage of energy released by dissolvable tablets in human fluids over time, submitted by a team of students at Kalasalingam Academy of Research and Education. It includes a declaration of originality, a bonafide certificate, acknowledgments, and an abstract outlining the study's objectives and methodologies. The project employs mathematical techniques and MATLAB for data analysis, contributing to the understanding of dissolution processes in pharmaceuticals.

Uploaded by

omsai152005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

211MAT1301

The document presents a project report on the maximum and minimum percentage of energy released by dissolvable tablets in human fluids over time, submitted by a team of students at Kalasalingam Academy of Research and Education. It includes a declaration of originality, a bonafide certificate, acknowledgments, and an abstract outlining the study's objectives and methodologies. The project employs mathematical techniques and MATLAB for data analysis, contributing to the understanding of dissolution processes in pharmaceuticals.

Uploaded by

omsai152005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

MAXIMUM AND MINIMUM PERCENTAGE OF TABLET

DISSOLVED IN THE HUMAN FLUIDS WITH RESPECT TO


TIME

Submitted by

RAYALA VAMSI(9924008083)
V.AJAY KKUMAR REDDY(9924004092)
G.OM SAI(99240040927)
G. VINAY VENKATA MANI HARI(99240040228)

In partial fulfillment for the course

of

Linear Algebra and Calculus


(211MAT1301)

SCHOOL OF FRESHMAN ENGINEERING

KALASALINGAM ACADEMY OF RESEARCH AND EDUCATION


(DEEMED TO BE UNIVERSITY)
KRISHNANKOIL 626 126

1 2023 – 2024
Academic Year:
KALASALINGAM ACADEMY OF RESEARCH AND EDUCATION
(DEEMED TO BE UNIVERSITY)
KRISHNANKOIL 626 126

DECLARATION BY THE STUDENT

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

of M A T H E S W A R A N . M Department of Mathematics, Kalasalingam Academy of Research and

Education, Krishnankoil and it has not been submitted for the award of any degree, diploma,

associateship, fellowship of any University or Institution.

STUDENT
REGISTER. No: STUDENT NAME
SIGNATURE
99240040927 G.OMSAI

99240040228 G.VINAY VENKATA MANI HARI

9924004092 V.AJAY KUMAR REDDY

9924008083 RAYALA VAMSI

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

ENERGY REALESED BY HUMAN FLUIDS WIT H RESPECT TO TIME” is the bonafide

work of R AY AL A VAMSI,G.OMS AI,G. VI N AY VEN K AT A M ANI H ARI, V. AJ AY

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.

HEAD OF THE DEPARTMENT SUPERVISOR

Project Viva-voce held on 26/12/2024

Internal Examiner External Examiner

3
ACKNOWLEDGEMENT

I want to thank Mr.M Matheswaran Assistant Professor in


Mathematics for his help and
guidance during the creation of this report & Dean of the School
of Freshmen Engineering for
providing us with the opportunity to work on this project support
and advice were incredibly
valuable and made a big difference. Without his assistance, this
report wouldn't have been
possible. I'm truly grateful for his support throughout the
process.
I would like to express my sincere gratitude to the University
and all its faculty

4
ABSTRACT

This project investigates the calculation of the


percentage of energy released by a dissolvable
tablet over specific time intervals. The study aims
to understand the rate and efficiency of energy
release, offering insights into the dynamics of
dissolution processes. By collecting and
analyzing experimental data, the project employs
mathematical techniques to determine the
percentage of energy released at regular time
intervals. The results are graphically represented
to highlight trends and variations. This study
contributes to a broader understanding of energy
dynamics in chemical reactions and their
practical applications in pharmaceuticals and
other industries.---

5
LIST OF TABLES

S. NO. TITLE PAGE NO


1.1
2.1
2.2
3.1
3.2
4.1
4.2

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

S. NO. TITLE PAGE NO


1.1
2.1
2.2
3.1
3.2
4.1
4.2

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

CHAPTER TITLE PAGE NO


NO.
ABSTRACT i
LIST OF TABLES ii
LIST OF FIGURES iii
1 INTRODUCTION 1
1.1 General
1.2 Sub-topics
2 SOLUTION TO A PROBLEM IN ANALYTICAL
APPROACH
2.1 Sub-topics 1
2.2 Sub-topics 2
3 SOLUTION TO A PROBLEM USING MATALB
3.1 Sub-topics 1
3.2 Sub-topics 2
4 CONCLUSION AND FUTURE WORK
REFERNCES

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 COMMAND WINDOW


• The COMMAND HISTORY

• The WORKSPACE
• The CURRENT DIRECTORY
• The HELP BROWSER
• The START button

Figure 1.1: The graphical interface to the MATLAB workspace


9
When MATLAB is started for the first time, the screen looks like the one that shown in the
Figure 1.1. This illustration also shows the default configuration of the MATLAB desktop. You
can customize the arrangement of tools and documents to suit your needs.

Using MATLAB as a calculator

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

>> 4*x ans =


28.0000

Quitting MATLAB

To end your MATLAB session, type quit in the Command Window, or select File →

Exit MATLAB in the desktop main menu.

1.1.2 Creating MATLAB variables

MATLAB variables are created with an assignment statement. The syntax of variable
assignment is

variable name = a value (or an expression)

10
For example,

>> x = expression

where expression is a combination of numerical values, mathematical operators, variables,


and function calls. On other words, expression can involve:

 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

and, from previous example

>> 1+2*3
ans = 7

By adding parentheses, these two expressions give different results: 9 and 7.

Controlling the appearance of floating-point number

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.

>> format short


>> x=163.6667

If we want to see all 15 digits, we use the command format long

>> format long


>> x= 1.636666666666667e+002

To return to the standard format, enter format short, or simply format.


There are several other formats. For more details, see the MATLAB documentation, or type
help format.

Managing the workspace

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.

Keeping track of your work session

It is possible to keep track of everything done during a MATLAB session with the diary
command.

>> diary

or give a name to a created file,

>> diary FileName

where FileName could be any arbitrary name you choose.


The function diary is useful if you want to save a complete MATLAB session. They save all
input and output as they appear in the MATLAB window. When you want to stop the recording,
enter diary off. If you want to start recording again, enter diary on. The file that is created is a
simple text file. It can be opened by an editor or a word processing program and edited to
remove extraneous material, or to add your comments. You can use the function type to view
the diary file or you can edit in a text editor or print. This command is useful, for example in
the process of preparing a homework or lab submission.

Entering multiple statements per line

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.

>> a=7; b=cos(a), c=cosh(a)

b=
0.6570
c=
548.3170
13
Miscellaneous commands

Here are few additional useful commands:

 To clear the Command Window, type clc

 To abort a MATLAB computation, type ctrl-c

 To continue a line, type . . .

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

>> help Command

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.

>> lookfor inverse

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:

Use on-line help to request info on a specific function

>> help sqrt

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.

>> doc plot


14
Use lookfor to find functions by keywords. The general form is

>> lookfor FunctionName

1.1.3 Mathematical functions

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.

Table 1.1: Elementary functions


cos(x) Cosine abs(x) Absolute value
sin(x) Sine sign(x) Signum function
tan(x) Tangent max(x) Maximum value
acos(x) Arc cosine min(x) Minimum value
asin(x) Arc sine ceil(x) Round towards +∞
atan(x) Arc tangent floor(x) Round towards −∞
exp(x) Exponential round(x) Round to nearest integer
sqrt(x) Square root rem(x) Remainder after division
log(x) Natural logarithm angle(x) Phase angle
log10(x) Common logarithm conj(x) Complex conjugate

In addition to the elementary functions, MATLAB includes a number of predefined constant


values. A list of the most common values is given in Table 1.2.

Table 1.2: Predefined constant values

NaN Not a number

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.

Creating simple plots

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:

Figure 1.1: Plot for the vectors x and y


16
>> x = 0:pi/100:2*pi;
>> y = sin(x);
>> plot(x,y)

Adding titles, axis labels, and annotations

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.

Figure 1.2: Plot of the Sine function

>> xlabel(’x = 0:2\pi’)


>> ylabel(’Sine of x’)
>> title(’Plot of the Sine function’)

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.

Figure 1.3: Typical example of multiple plots

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’)

where style_color_marker is a triplet of values from Table 2.3.


To find additional information, type help plot or doc plot.

Table 1.3: Attributes for plot

1.1.4 Matrix generation

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 matrix is an array of numbers. To type a matrix into MATLAB you must

 begin with a square bracket, [

 separate elements in a row with spaces or commas (,)

 use a semicolon (;) to separate rows


20
 end the matrix with another square bracket, ].

>> A = [1 2 3; 4 5 6; 7 8 9]

MATLAB then displays the 3 × 3 matrix as follows,

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;

The row vector has 51 elements.

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,

>> theta = linspace(0,2*pi,101)

divides the interval [0, 2π] into 100 equal subintervals, then creating a vector of 101 elements.

Colon operator in a matrix

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

is the second row elements of A.


The colon operator can also be used to extract a sub-matrix from a matrix A.

22
>> A(:,2:3)
ans =
2 3
5 6
8 0

A(:,2:3) is a sub-matrix with the last two columns of A.


A row or a column of a matrix can be deleted by setting it to a null vector, [ ].

>> 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 = A([2 3],[1 2])

B=
4 5
7 8

To interchange rows 1 and 2 of A, use the vector of row indices together with the colon
operator.

>> C = A([21 3],:)


C =
4 5 6
1 2 3
7 8 0

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 submatrix comprising the intersection of rows p to q and columns r to s is denoted by


A(p:q,r:s).
As a special case, a colon (:) as the row or column specifier covers all entries in that row or
column; thus
• A(:,j) is the jth column of A, while

• A(i,:) is the ith row, and

• A(end,:) picks out the last row of A.

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

>> A(end:-1:1,end) ans =


9
6
3

24
>> A([1 3],[2 3])
ans =
2 3
8 9

Deleting row or column

To delete a row or column of a matrix, use the empty vector operator, [ ].

>> 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

>> A = [A(1,:);A(2,:);[7 8 0]]


A =
1 2 3
4 5 6
7 8 0

Matrix A is now restored to its original form.

Dimension

To determine the dimensions of a matrix or vector, use the command size. For example,

>> size(A)
ans =
3 3

means 3 rows and 3 columns. Or more explicitly with,

>> [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.

Table 1.4: Elementary matrices


eye(m,n) Returns an m-by-n matrix with 1 on the main diagonal
eye(n) Returns an n-by-n square identity matrix
zeros(m,n) Returns an m-by-n matrix of zeros
ones(m,n) Returns an m-by-n matrix of ones
diag(A) Extracts the diagonal of matrix A
rand(m,n) Returns an m-by-n matrix of random numbers

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.

Table 1.5: Special matrices


hilb Hilbert matrix
invhilb Inverse Hilbert matrix
magic Magic square
pascal Pascal matrix
toeplitz Toeplitz matrix
vander Vandermonde matrix
wilkinson Wilkinson’s eigenvalue test matrix
26
Matrix functions

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

Table 1.6: Matrix functions

1.1.5 M-File Scripts

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:

1. to create a file with a list of commands,

2. save the file, and


3. run the file.

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

>> edit filename.m

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:

 Variables already existing in the workspace may be overwritten.

 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.

Anatomy of a M-File function

This simple function shows the basic parts of an M-file.

function f = factorial(n) (1)


% FACTORIAL(N) returns the factorial of N. (2)
% Compute a factorial value. (3)

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

Table 1.7: Anatomy of a M-File function

Part no. M-file element Description


(1) Function Define the function name, and the
definition line number and order of input and output
arguments
(2) H1 line A one line summary description
of the program, displayed when you
request Help
(3) Help text A more detailed description of
the program
(4) Function body Program code that performs
the actual computations

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.

Table 1.8: Difference 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 [outputs] = function_name(inputs)

Function file can have none, one, or several output arguments. Table 4.3 illustrates some
possible combinations of input and output arguments.

Table 1.9: Example of input and output arguments


function C=FtoC(F) One input argument and
one output argument
function area=TrapArea(a,b,h) Three inputs and one output
function [h,d]=motion(v,angle) Two inputs and two outputs

Input to a script file

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.

1. The variable is defined in the script file.

2. The variable is defined in the command prompt.

3. The variable is entered when the script is executed.

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.

% This script file calculates the average of points


% scored in three games.
% The point from each game are assigned to a variable
% by using the ‘input’ command.

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).

Table 1.10: disp and fprintf commands

. Provide limited control over the appearance of output

. Provide total control over the appearance of output

31
1.1.6 Control flow operators

MATLAB is also a programming language. Like other computer programming languages,


MATLAB has some decision making structures for control of command execution. These
decision making or control flow structures include for loops, while loops, and if-else-end
constructions. Control flow structures are often used in script M-files and function M-files.
By creating a file with the extension .m, we can easily write and run programs. We do not need
to compile the program since MATLAB is an interpretative (not compiled) language.
MATLAB has thousand of functions, and you can add your own using m-files.
MATLAB provides several tools that can be used to control the flow of a program (script or
function). In a simple program as shown in the previous Chapter, the commands are executed
one after the other. Here we introduce the flow control structure that make possible to skip
commands or to execute specific group of commands.

MATLAB has four control flow structures: the if statement, the for loop, the while loop, and
the switch statement.

The ‘‘if...end’’ structure

MATLAB supports the variants of “if” construct.

 if ... end

 if ... else ... end


 if ... elseif ... else ... end

The simplest form of the if statement is

if expression statements
end

It should be noted that:

• elseif has no space between else and if (one word)

• no semicolon (;) is needed at the end of lines containing if, else, end

• indentation of if block is not required, but facilitate the reading.

• the end statement is required

32
Relational and logical operators

A relational operator compares two numbers by determining whether a comparison is true


or false. Relational operators are shown in Table 5.1.

Table 5.1: 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.

The ‘‘for...end’’ loop

In the for ... end loop, the execution of a command is repeated at a fixed and predeter-
mined number of times. The syntax is

for variable = expression statements


end

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

The ‘‘while...end’’ loop

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

The statements are executed as long as expression is true.

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.

Other flow structures

• 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.

Table: Operator precedence

1 Parentheses
2 Transpose (. '), power (.ˆ), matrix power (ˆ)
3
4

5
6
7

8 Element-wise AND, (&)


9 Element-wise OR, (|)

Saving output to a file

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:

1. Open a file using fopen

2. Write the output using fprintf

3. Close the file using fclose

35
CHAPTER 2

MAXIMUM AND MINIMUM


PERCENTAGE OF TABLET DISSOLVED IN THE
HUMAN FLUIDS WITH RESPECT TO TIME

Introduction :Tablets are widely used in the pharmaceutical industry


as a convenient and effective means of delivering medication to the
body. Their ability to release energy or active compounds over time
plays a crucial role in their efficacy. This project focuses on
analyzing the energy release of a tablet, specifically measuring the
percentage released at regular time intervals. By studying the
dissolution process, this research sheds light on the chemical and
physical interactions within the tablet and its behavior in simulated
biological environments. Understanding these processes has
implications for improving drug delivery systems, optimizing dosage
forms, and enhancing therapeutic outcomes.The primary goal of this
study is to calculate the percentage of energy released by a tablet
as it dissolves over time. This requires a multidisciplinary approach,
combining principles of chemistry, biology, and mathematics. By
exploring the manufacturing data, chemical composition, dissolution
mance. time, and physiological effects of the tablet, this project aims
to provide a comprehensive understanding of its perfor

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

The table give below shows percentage of water soluble table


dissolved overtime in minutes during a controlled experiment:

Using the data perform the following tasks


1.Generate function c(t) to represent the percentage dissolved c as a
function of time t using polynomial fitting
2.Plot the curve c(t)
3.Compute first and second derivative for the function
4.Plot the curve for c’(t) and c’’(t)
5.Evalute the maxima and minimum dissolution rates

1
CHAPTER 4

The table give below shows percentage of water soluble table


dissolved overtime in minutes during a controlled experiment:

Using the data perform the following tasks


1.Generate function c(t) to represent the percentage dissolved c as a
function of time t using polynomial fitting
2.Plot the curve c(t)
3.Compute first and second derivative for the function
4.Plot the curve for c’(t) and c’’(t)
5.Evalute the maxima and minimum dissolution rates
REFERENCES

1. Grewal B.S., “Higher Engineering


Mathematics”, Khanna Publishers, New
Delhi,
41st Edition, 2011.
2. Ramana B.V., “Higher Engineering
Mathematics”, Tata McGraw Hill Co. Ltd.,
New Delhi, 11th Reprint, 2010.
3. Veerarajan T., Engineering Mathematics
(for First Year), Tata McGraw Hill Pub.
Co. Ltd., New Delhi, Revised Edition, 2007
4. James Stewart, Calculus: Early
Transcendentals, Cengage Learning, 7th
Edition,
New Delhi, 2015.

You might also like