FCPS Assignment-1 Solution
FCPS Assignment-1 Solution
of Technology Kharagpur
Matlab Basics
3. Click on the ‘New’ button on left corner of menu bar to create a new script and save it
with ‘.m’ extension.
5. Use ‘help’ followed by Matlab’s in-built function name to know about the function
description. For example ‘help ode45’
NPTEL Online Certification Courses Indian Institute
of Technology Kharagpur
Output:
Determinant of A
-15.0000
Inverse of A
-0.2667 0.5333 -0.0667
0.1333 0.7333 -0.4667
0.3333 -0.6667 0.3333
Transpose of A
1 3 5
2 1 0
3 2 4
Rank of A
ans =
Eigen values of A
NPTEL Online Certification Courses Indian Institute
of Technology Kharagpur
ans =
7.3544
-2.2577
0.9034
Adjoint of A
ans =
Lorenz model is a system of 3 non-linear ordinary differential equations that relate the
properties of a two-dimensional fluid layer uniformly warmed from below and cooled from
above:
𝑥̇ = 𝜎(𝑦 − 𝑥)
𝑦̇ = 𝑥(𝜌 − 𝑧) − 𝑦
𝑧̇ = 𝑥𝑦 − 𝛽𝑧
Here, 𝑥 ∝ the rate of convection, 𝑦 ∝ the horizontal temperature variation, and 𝑧 ∝ the
vertical temperature variation. The parameters 𝜎, 𝜌, and 𝛽 are proportional to the Prandtl
number, Reyleigh number, and certain physical dimension of the layer itself respectively
(all are assumed to be positive).
Considering 𝜎 = 10, 𝛽 = 8/3, 𝜌 = 28, and the initial values of (𝑥, 𝑦, 𝑧) = (1,1,1), the
following Matlab code simulate Lorenz model over a time window of 100 units.
NPTEL Online Certification Courses Indian Institute
of Technology Kharagpur
sigma = 10;
beta = 8/3;
rho = 28;
% Inline function definition for Lorenz model
f = @(t,a) [-sigma*a(1) + sigma*a(2); rho*a(1) - a(2) -
a(1)*a(3); -beta*a(3) + a(1)*a(2)];
% Solving ODE using Runge-Kutta 4th/5th order ODE solver
[t,a] = ode45(f,[0 100],[1 1 1]);
% plotting in 3 dimensions
plot3(a(:,1),a(:,2),a(:,3))
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
NPTEL Online Certification Courses Indian Institute
of Technology Kharagpur
Detailed Solution:
𝑎𝑑𝑗(𝐴)
Adjoint matrix adj(A)= transpose of co-factor matrix and 𝐴−1 = |𝐴|
Since, determinant of a square matrix is same as determinatnt of its transpose, determinant of co-factor
matrix of A is det(det(A)*inv(A))=225
In data-driven predictive control using regression trees the regions of controllable variables are
predicted.
a. True
b. False
Question 3
Detectors in a cyber-physical systems are usually used in order to detect if there is a requirement for
better cost optimization in control strategy.
a. True
b. False
Question 4
Using SUMO as a network simulator with a mobility simulator like Omnet++ we can simulate a vehicle
platoon
a. True
b. False
Question 5
Question 6
Robot Operating System can manage low-level device control in a lab scale autonomous vehicle setup.
a. True
b. False
Question 7
The following code evaluates the van der Pol ODEs for 𝜇 = 1 and intial value 𝑦1 = 2, 𝑦2 = 0 for 0 to 20
units of time.
Correct answer: c
Detail Explanation:
𝑑𝑦 𝑦̇ 𝑦2
Since, 𝜇 = 1, = [ 1 ] = [(1 2 )𝑦 ]
𝑑𝑡 𝑦̇ 2 − 𝑦1 2 − 𝑦1
The definition of Matlab’s ode45 function is ode45(ODEFUN,TSPAN,Y0) where ODEFUN(T,Y) is a
function handle, TSPAN is the time duration and Y0 is the initial condition. Type ‘help ode45’ in Matlab
command window to know more about this function’s details.
NPTEL Online Certification Courses Indian Institute
of Technology Kharagpur
Question 8
Find out using Matlab, which one of the following matrices are Schur stable.
1 2
1. 𝐴1 = [ ]
−1 3
−1 − 0.2
2. 𝐴2 = [ ]
1 0.3
−1 0.2
3. 𝐴3 = [ ]
0.1 0.3
1 2
4. 𝐴4 = [ ]
−1 3
1 − 0.2
5. 𝐴5 = [ ]
−1 0.3
Detailed Answer:
If all eigenvalues of a matrix A have norm strictly less than one; i.e. the spectral radius of A is less than
one, then the matrix A is Schur stable.
norm(max(eig(A1)),Inf) = 2.2361
norm(max(eig(A2)),Inf) = 0.1217
norm(max(eig(A3)),Inf) = 0. 3152
norm(max(eig(A4)),Inf) = 2.2361
norm(max(eig(A5)),Inf) = 1.2179
Question 9
Find out which of the matrices below are orthogonal using Matlab. We call a matrix 𝐴 orthogonal when
𝐴 ∗ 𝐴𝑇 = 𝑖𝑑𝑒𝑛𝑡𝑖𝑡𝑦.
2 4 6
1. 𝐴1 = [ 1 3 − 5 ]
−2 7 9
−1 0
2. 𝐴2 = [ ]
0 −1
2 3
3. 𝐴3 = [ ]
1 2
2 −2 1
4. 𝐴4 = [ 1 2 2 ]
2 1 −2
−0.6059 0.7956
5. 𝐴5 = [ ]
0.7956 0.6059
Correct Answer: 2, 5
NPTEL Online Certification Courses Indian Institute
of Technology Kharagpur
Question 10
If all eigenvalues of a matrix A have norm strictly less than one; i.e. the spectral radius of A is less than
one, then the matrix A is Schur stable. Fill in the blank such that the following Matlab code snippet
checks whether matrix A is schur stable and returns 𝑡𝑟𝑢𝑒 or 𝑓𝑎𝑙𝑠𝑒. Note that Matlab function
𝑛𝑜𝑟𝑚(𝑋, 𝐼𝑛𝑓) returns the infinity norm of a vector X i.e. ||𝑋||∞
norm(max(_____),Inf)<_
a. poles(A),0
b. eig(A), 0
c. eig(A),1
d. rank(A),rank(AT)
Question 11
Write the Matlab command to find the determinant of the co-factor matrix of 𝐴
a. det(transpose(det(A)*inv(A)))
b. det(A)*inv(transpose(A))
c. transpose(det(transpose(A))*inv(A))
d. -det(A)*inv(A)
Detailed Solution:
𝑎𝑑𝑗(𝐴)
Adjoint matrix adj(A)= transpose of co-factor matrix and 𝐴−1 = |𝐴|
Therefore, transpose of co-factor matrix = adjoint matrix = 𝐴−1 × |A|
And, determinant of co-factor matrix = det(transpose(det(A)*inv(A)))
Question 12
max() function is used to find ___ _ ___ and abs() function is used to find __ __ ___.