0% found this document useful (0 votes)
19 views5 pages

Print Matlab

MATLAB is a numerical programming language designed for matrix manipulation and algorithm implementation, developed by MathWorks in the late 1970s. The document provides several MATLAB programs demonstrating various functionalities, including finding eigenvalues, plotting functions, and solving equations. Each program includes code snippets and their respective outputs, showcasing MATLAB's capabilities in numerical methods.

Uploaded by

satyajeet32422
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)
19 views5 pages

Print Matlab

MATLAB is a numerical programming language designed for matrix manipulation and algorithm implementation, developed by MathWorks in the late 1970s. The document provides several MATLAB programs demonstrating various functionalities, including finding eigenvalues, plotting functions, and solving equations. Each program includes code snippets and their respective outputs, showcasing MATLAB's capabilities in numerical methods.

Uploaded by

satyajeet32422
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/ 5

MATLAB

INTRODUCTION:- MATLAB (meaning MATrix LABoratory) is


a numerical, fourth generations programming language built around an
interactive programming environment . There is no need to compile, link
and execute after each correction, thus MATLAB programs can be
developed in much shorter time than equivalent c and c++ programs. It
has many built in functions that make learning of numerical methods
much easier and interesting developed by mathworks, MATLAB allows
matrix manipulations , plotting of functions and data , implementation of
algorithms , creation of user interfaces and interfacing with programs of
other language . MATLAB was created in the late 1970’s by cleve Moler .
MATLAB Programs and Outputs
MATLAB Program 1: Find Eigenvalues of a Matrix
MATLAB Code:
A = [1 7 3; 2 9 12; 5 22 7];
S = eig(A)

Output:
25.5548
-0.5789
-7.9759

MATLAB Program 2: Parametric Plot and Function Plot


MATLAB Code:
xt = @(t) cos(3*t);
yt = @(t) sin(2*t);
fplot(xt, yt)
f = @(x) (exp(-x)./x) - (exp(-(2+x))./(2+x));
x = 10:0.1:50;
plot(x, f(x))

Output:
A figure window opens with two plots as follows.
MATLAB Program 3: Solve General Quadratic Equation
MATLAB Code:

syms x

eqn = a*x^2 + b*x + c==0;

solx = solve(eqn,x)

Output:

solx =

-(b + (b^2 - 4*a*c)^(1/2))/(2*a)


-(b - (b^2 - 4*a*c)^(1/2))/(2*a)

MATLAB Program 4: Solve Power Equation


MATLAB Code:
syms x
eqn = x^5 == 3125;
S = solve(eqn, x)

Output:

5
- (2^(1/2)*(5 - 5^(1/2))^(1/2)*5i)/4 - (5*5^(1/2))/4 - 5/4
(2^(1/2)*(5 - 5^(1/2))^(1/2)*5i)/4 - (5*5^(1/2))/4 - 5/4
(5*5^(1/2))/4 - (2^(1/2)*(5^(1/2) + 5)^(1/2)*5i)/4 - 5/4
(5*5^(1/2))/4 + (2^(1/2)*(5^(1/2) + 5)^(1/2)*5i)/4 - 5/4

MATLAB Program 5: Solve Trigonometric Equation


MATLAB Code:
syms x
eqn = cos(x) == x^2 - 1;
S = solve(eqn, x)

Output:
S=

-1.176501939901832400447377268731
MATLAB Program 6: Solve a quadratic Equation
MATLAB Code:
syms x

eqn =3*x^2+5*x+2==0;

S=solve(eqn,x)

Output:

S =

-1
-2/3

MATLAB Program 7: Solve a cubic equation

MATLAB Code:
syms x

eqn =3*x^3-5*x-14==0;

S=solve(eqn,x)

Output:
S =

2
- (3^(1/2)*2i)/3 - 1
(3^(1/2)*2i)/3 - 1

MATLAB Program 8: Solve system of three linear Equations in three Variables


MATLAB Code:
syms x y z
eqn1 = 2*x + y + z == 2;
eqn2 = -x + y - z == 3;
eqn3 = x + 2*y + 3*z == -10;
sol = solve([eqn1, eqn2, eqn3], [x, y, z]);
xSol = sol.x;

ySol = sol.y;

zSol = sol.z;

Output:
x = 3, y = 1, z = -5
MATLAB Program 9: Find inverse of a Matrix
MATLAB Code:
A = [1 0 2; -1 5 0; 0 3 -9];
I = inv(A)

Output:

I=

0.8824 -0.1176 0.1961


0.1765 0.1765 0.0392
0.0588 0.0588 -0.0980

You might also like