MATLAB Questions and Answers - 1
MATLAB Questions and Answers - 1
19BCT0003
Experiment 1-A
>> a = 9.8^(1/5)
a=
1.5785
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
a=
0.7071
v. e13
>> x = exp(13)
x=
4.4241e+05
vi. √488
>> a = sqrt(488)
a=
22.0907
x=
3 4 5 6 7 8 9 10
a=
Exercise – 2
Answer:
>> 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
>> 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
Aim: To learn and practice some basic graph plotting commands in MATLAB
EXERCISE - 1
(iii) Indicate the x-label, y-label, legend, title of the graph. Set the thickness of the line as 2 points.
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:
Sol: