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

Application Part1 (Matlab)

MATLAB can find roots of single-variable equations using fzero or solve. Fzero locates one root given an initial guess, while solve finds all roots of polynomial equations by providing expressions. Both can be used to locate roots of nonlinear equations. Linear algebraic equations with multiple unknowns can be solved using matrix division operators / and \ to find the solution vector.

Uploaded by

SyAeRaN
Copyright
© Attribution Non-Commercial (BY-NC)
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)
24 views

Application Part1 (Matlab)

MATLAB can find roots of single-variable equations using fzero or solve. Fzero locates one root given an initial guess, while solve finds all roots of polynomial equations by providing expressions. Both can be used to locate roots of nonlinear equations. Linear algebraic equations with multiple unknowns can be solved using matrix division operators / and \ to find the solution vector.

Uploaded by

SyAeRaN
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 2

Roots of Equations

MATLAB is capable of locating roots of single algebraic and transcendental


equations. We can either use the MATLAB function fzero or solve to find the roots
of the nonlinear equations.

 The fzero function is designed to located one root of a single function.

x = fzero(inline(‘f’),x0)

where f is the function you are analyzing, x0 is the initial guess.

Note that one or two guesses can be employed. If two guesses are employed, they are
assumed a bracket a root.

Example: Locate the root of   0.9


1.7 5  0. Given x0 = 1.

>> x0=1;
>> fzero(inline('0.9*x^2+1.7*x-5'),x0)

ans =
1.5948

Activity: Locate the root of       0. Given x0 = 1.

Example: Find the root of    2 3  0. Given xa = 1, xb = 4.

>> x0 = [1 4];
>> fzero(inline('x^2-2*x-3'),x0)

ans =
3.0000

Activity: Find the root of   2


 15  0. Given xa = 1, xb = 5.

 If S is a symbolic expression,

Solve(S)

attempts to find values of the symbolic variable in S for which S is zero. This function
is most useful for the solving polynomials since it provides expressions for all roots.

Example: Find the root of   2


 15  0.
>> syms x
>> f = 2*x^2 + x - 15;
>> solve(f)

ans =
5/2
-3

Activity: Locate the root of    2 3  0.

Linear Algebraic Equations


MATLAN uses the division terminology to describe the solution of a general system
of simultaneous equations. The two equation symbols, slash, / , and backslash, \ , are
used for the two situation where the unknown matrix appears on the left or right of
the coefficient matrix.

X = A\B Denotes the solution to the matrix equation AX = B


X = B/A Denotes the solution to the matrix equation XA = B

Example:
Solve
3x1 – 0.1x2 – 0.2x3 = 7.85
0.1x1 + 7x2 – 0.3x3 = -19.3
0.3x1 – 0.2x2 + 10x3 = 71.4

>> A = [3 -0.1 -0.2; 0.1 7 -0.3; 0.3 -0.2 10];


>> B=[7.85 -19.3 71.4]';
>> X = A\B;
>> x1 = X(1)
>> x2 = X(2)
>> x3 = X(3)

Activity:
Solve
12x1 – 3x2 – x3 = 15
x1 + 8x2 + x3 = 20
2x1 – x2 + 10x3 = 30

You might also like