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

MATLAB Questions and Answers - 1

The document appears to be an experiment report submitted by a student named Swastik Shukla for their MATLAB course. It includes exercises demonstrating basic MATLAB commands like calculating numerical values, generating lists, matrix operations, plotting 2D curves, and solving polynomials. The student provides code and output to solve problems involving roots, logarithms, trigonometric functions, matrices, and graphing sinusoidal curves over the domain -3pi to 3pi.

Uploaded by

Swastik Shukla
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views

MATLAB Questions and Answers - 1

The document appears to be an experiment report submitted by a student named Swastik Shukla for their MATLAB course. It includes exercises demonstrating basic MATLAB commands like calculating numerical values, generating lists, matrix operations, plotting 2D curves, and solving polynomials. The student provides code and output to solve problems involving roots, logarithms, trigonometric functions, matrices, and graphing sinusoidal curves over the domain -3pi to 3pi.

Uploaded by

Swastik Shukla
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Name: Swastik Shukla Reg. no.

19BCT0003

Experiment 1 : Introduction To MATLAB

Experiment 1-A

Basic MATLAB Commands


Aim: To study and practice some basic MATLAB commands and functions.
Exercise – 1
Find the numerical values of the following:
i. The fifth root of 9.8

>> a = 9.8^(1/5)

a=

1.5785

ii. 2 to the eighth power


>> x = 2^8

x=

256

iii. The angle whose tangent is 0.5 (both in degrees and radians)
For radians:
>> x = atan(0.5)

x=

0.4636

For degrees:
>> x = atand(0.5)

x=

26.5651

iv. Cosine of π/4


>> a = cos(pi/4)

a=

0.7071

v. e13
>> x = exp(13)

x=

4.4241e+05
vi. √488
>> a = sqrt(488)

a=

22.0907

vii. Generate a list of natural numbers from 3 to 10.


>> x = 3:1:10

x=

3 4 5 6 7 8 9 10

viii. Create a list of 10 equally distributed numbers from 0 to 1.


>> a = linspace(0,1,10)

a=

0 0.1111 0.2222 0.3333 0.4444 0.5556 0.6667 0.7778 0.8889 1.0000

Exercise – 2

Answer:

>> A =[0 1;-2 -3];

>> B =[1 0;3 -2];

>> C =[0 -1;-2 2];

>> A+B
ans =

1 1

1 -5

>> A-B

ans =

-1 1

-5 -1

>> det(A)

ans =

>> inv(A)

ans =

-1.5000 -0.5000

1.0000 0

>> A = [2 -3 1;4 6 2;0 -2 8];

>> B = A(2:3,:)
B=

4 6 2

0 -2 8

>> C = [1 3 2];

>> A(4,:) = C;

>> D = A

D=

2 -3 1

4 6 2

0 -2 8

1 3 2
Experiment 1-B

Plotting of 2-D Curves

Aim: To learn and practice some basic graph plotting commands in MATLAB
EXERCISE - 1

2. For the domain −3𝜋 ≤ 𝑥 ≤ 3𝜋

(i) Plot the curve y=sin x.

(ii) On the same graph superimpose the curve y=cos x.

(iii) Indicate the x-label, y-label, legend, title of the graph. Set the thickness of the line as 2 points.

(iv) Show the curves in two different colors.

Sol:
Exercise - 2

1. Define the symbolic variables a, b, c, and x; then find the roots of the quadratic equation ax^2+bx+c = 0. By
using 'subs' command find the roots of the following quadratic equations:

(i) x2 – 3x + 2 = 0

(ii) x2 + 12x + 35 = 0

Sol:

(i)
(ii)
2. Find the roots of the polynomial:

x7 + 4x6 – 16x5 + 40x4 + 89x3 + 16x2 – 234x + 180 = 0

Sol:

You might also like