Docsity

MATLAB Essentials: Commands, Calculus, & Linear Programming, Cheat Sheet of Mathematics

Toggle sidebar
bg1
DECLERATION
I hereby declare that the project work entitled “MATLAB” is a general concept of
mathematical problems, original work done by me, and this project work is
submitted in the requirements for the award of the degree of Bachelor Second
Semester. The results enrolled in the report have not been submitted to any other
university or institute for the award of degree of BCA. I attest that all data presented
in this report is accurate and was obtained through experimentation conducted by
me or under my direct supervision.
Furthermore, I confirm that all sources used in the preparation of this report have
been appropriately cited and referenced in accordance with the guidelines provided
by the instructor. Any assistance received from individuals or sources has been
acknowledged in this report.
I understand that any act of academic misconduct, including plagiarism, will not be
tolerated and may result in severe penalties, including but not limited to, loss of
marks or course failure.
I take full responsibility for the content of this report and acknowledge that I have
read and understood the guidelines provided by the instructor.
Signed: Mahendra Singh Mahara
Date: April 30, 2023
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download MATLAB Essentials: Commands, Calculus, & Linear Programming and more Cheat Sheet Mathematics in PDF only on Docsity!

DECLERATION

I hereby declare that the project work entitled “MATLAB” is a general concept of

mathematical problems, original work done by me, and this project work is

submitted in the requirements for the award of the degree of Bachelor Second

Semester. The results enrolled in the report have not been submitted to any other

university or institute for the award of degree of BCA. I attest that all data presented

in this report is accurate and was obtained through experimentation conducted by

me or under my direct supervision.

Furthermore, I confirm that all sources used in the preparation of this report have

been appropriately cited and referenced in accordance with the guidelines provided

by the instructor. Any assistance received from individuals or sources has been

acknowledged in this report.

I understand that any act of academic misconduct, including plagiarism, will not be

tolerated and may result in severe penalties, including but not limited to, loss of

marks or course failure.

I take full responsibility for the content of this report and acknowledge that I have

read and understood the guidelines provided by the instructor.

Signed: Mahendra Singh Mahara

Date: April 30 , 2023

Table of Contents

  • Introduction to MATLAB
  • Gitting starting/quitting the MATLAB
  • MATLAB Desktop Tools
  • Basic Commands For MATLAB
  • Lab Experiment in MATLAB
  • Leanear Programming Lab
  • Limit And Continuity
  1. Command History: Statements you enter in the Command Window are

logged in the Command History. In the Command History, you can view

previously run statements, and copy and execute selected statements.

  1. Current Directory Browser: MATLAB file operations use the current

directory reference point. Any file you want to run must be in the current

directory or on the search path.

  1. Workspace: The MATLAB workspace consists of the set of variables

(named arrays) built up during a MATLAB session and stored in memory.

  1. Editor/Debugger Window: Use the Editor/Debugger to create and debug

M-files.

Command Window

workspac

e

Command History

Current Directory Browser

Basic Commands For MATLAB

  • clear Command: Removes all variables from workspace.
  • clc Command: Clears the Command window and homes the cursor.
  • help Command: help displays help about that Topic if it exists.
  • Lookfor Command: Provides help by searching through all the first lines

of MATLAB help topics and returning those that contains a key word you

specify.

  • edit Command: enable you to edit (open) any M-file in Editor Window.

This command doesn’t open built-in function like, sqrt. See also type

Command.

  • more command: more on enables paging of the output in the MATLAB

command window, and more off disables paging of the output in the

MATLAB command window.

Notes:

  • A semicolon " ; " at the end of a MATLAB statement suppresses printing of

results.

  • If a statement does not fit on one line, use "... ", followed by Enter to

indicate that the statement continues on the next line.

For example:

S= sqrt (225) *30 /...

(20*sqrt (100)

  • If we don’t specify an output variable, MATLAB uses the variable ans (short

for answer), to store the last results of a calculation.

  • Use Up arrow and Down arrow to edit previous commands you entered in

Command Window.

  • Insert " % " before the statement that you want to use it as comment; the

statement will appear in green color.

Lab Experiment in MATLAB

1.3 Derivative of Exponential

a) f= e

x

b) f= x

9

c) f= sin x d) f= tan x e) f= cos x

f) f= log x g) f= log 10

x h) f= sin x

2

i) f= cos(3x

2

+2x+1)

j) f= e

x

/sin x

RESULT:

y = exp(x)

ans = exp(x)

y = x^

ans = 9*x^

y = sin(x)

ans = cos(x)

y=tan(x)

ans = 1+tan(x)^

y = cos(x)

ans = - sin(x)

y = log(x)

ans = 1/x

y = log(x)/log(10)

ans = 1/x/log(10)

y = sin(x)^

ans = 2sin(x)cos(x)

y = cos(3x^2+2x+1)

ans = - sin(3x^2+2x+1)(6x+2)

y = exp(x)/sin(x)

ans = exp(x)/sin(x)-exp(x)/sin(x)^2*cos(x)

1.4 Maxima and Minima of curve

a) f(x) = 2x

3

+3x

2

  • 12x+
  • Finding the result in MATLAB:
  • Finding the graph of this equation:
  • Finding the graph of the equation when interval [-2,2]

Output:

g = 6x^2+6x- 12

s = 1 - 2

Ans = 10

Ans = 37

1.5 Solving Differential Equation

a) solve first order of equation: y’= 5y

b) solve second order of equation: y”-y=0, y(0)= - 1, y’(0)= 2

2.1 Integration

i) F= x

n

ii) F= sin nt

2.2 Finding the Definite Integral Using MATLAB:

Output:

Ans=

  • 3/2exp(-t) + 1/2exp(t)
  • Area Calculation: -

Calculate the area between the x-axis. the curve y= x

3

  • 2x+5 and the ordinates at

x=1 and x=2.

Output:

The required area is ∫

2

1

3

  • 2x+5) dx.
  • Find the area under the curve: -

F(x)=x

2

cos(x) for - 4 ≤x≤9.

Output:

Output:

3.1 Solving the Higher order of equation in MATLAB

Solve: (x-3)

2

(x-7) =

Output:

Leanear Programming Lab

4. 1 Solving System of equation in MATLAB

Solve the equations: 5x+9y=5, 3x-6y=4.

Output:

4.2 Trapezoidal Rule using MATLAB.

Evaluate the integral x

4

within limit by using - 3 to 3 Trapezoidal rule

Solution:

Let n= 6

so, Y(x)= x

4

. Here a = - 3 and b = 3 therefore (b-a) = 6.

Also, h= (b-a)/n=6/6=

X: - 3 - 2 - 1 0 1 2 3
Y: 81 16 1 0 1 16 81

Output:

Answer= (½)[(81+81)+2(16+1+0+1+16)]

Ans= 115

4.4 Newton-Raphson Method in MATLAB.

Find the real root of the equation: cos(x)-3x+1 using NR method.

Output:

4.5 Gauss-Seidel Method

Find the root of following equation,

20x+y-2z=

3x+20y-z=- 18

2x_3y+20z=

Solution:

We start approximation by x0=y0=z0=0.

Let the given eq

n

in the form,

X= (1/20) (17-y+2z) -----------------(i)

Y= (1/20) (- 18 - 3x+z) ----------------(ii)

Z= (1/20) (25-2x+3y) ----------------(iii)

Result:

In[13]:= Limit[(x^8-256)/(x-2), x→ 2]

Out[13]= 1024

c) Lim (x^2+7x+3)/(9x^2+7x+2)

x → ∞

Solution:

In[15]:= Limit[(x^2+7x+3)(9x^2+7x+2), x→∞]

Out[15]= 1 9

d) Lim (Sqrt(x-1)- Sqrt(x))

x → ∞

Solution:

In[16]:= Limit[Sqrt[x-1]-Sqrt[x], x→∞]

Out[16]= 0

e) Lim (Sin x/x)

x → 0

Solution:

In[18]:= Limit[Sin[x]/x, x→ 0]

Out[18]= 1

f) Lim (sin4x/Sin5x)

x → 0

Solution:

In[19]:= Limit[Sin[4x]/Sin[5x], x→ 0]

Out[19]= 4 5

g) Lim tan(3x) - 2x/(3x-sin2x)

x → 0

Solution:

In[21]:= Limit[(Tan[3x]-2x)/(3x-Sin[2x]), x→ 0]

Out[21]= 1

h) Lim (sinx-cos)/(x- π/4)

x → π/

Solution:

In[22]:= Limit[Sin[x]-Cos[x])/(x-π/4), x→π/4]

Out[22]= 2

i) Draw the graph of x^2 (-3<=x<=3)

In[24]:= Plot[x ^ 2,{x,-3, 3}]

j) Draw the graph of 6-2x-x^2 (-3<=x<=3)

ln[25]:= Plot[6- 2 x-x^ 2,{x,-5, 3}]

  • 3 - 2 - 1

5

  • 4 - 2
    • 5

2