Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views2 pages

SH 1

The document is a MATLAB tutorial for Electrical Engineering students at Assiut University, covering various matrix operations, polynomial evaluations, and plotting techniques. It includes exercises on entering matrices, performing calculations, and generating plots using MATLAB commands. The tutorial aims to enhance students' understanding of MATLAB for control engineering applications.

Uploaded by

ahmed328osama
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)
7 views2 pages

SH 1

The document is a MATLAB tutorial for Electrical Engineering students at Assiut University, covering various matrix operations, polynomial evaluations, and plotting techniques. It includes exercises on entering matrices, performing calculations, and generating plots using MATLAB commands. The tutorial aims to enhance students' understanding of MATLAB for control engineering applications.

Uploaded by

ahmed328osama
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/ 2

Electrical Engineering Dept. Computers and Systems Prog.

Faculty of Engineering MATLAB for Control Engineers


Assiut University EC 332 (2004) - EEC 325 (2021)
3rd Year - 2024/2025 Sheet 1
Assiut University 2nd Semester Faculty of Engineering Introduction to MATLAB
Assiut University Faculty of Engineering

1) Consider the following matrices:


     
11 12 13 14 10 4 12
21 22 23 24 20 4  9  , D = [4 3 2 1]
    
A= 31 , B= , C =
32 33 34 30 4 6
41 42 43 44 40 4 2

i) Enter the matrices A, B, C and D into the MATLAB environment.


ii) What are the outputs of the following commands:

a) A(1:6) b) A(:,3)-3 c) A(2,:)+D


d) A(:,3:4)-B e) A([1,3],[2,4]) f) diag(A)
g) diag(C) h) diag(diag(A))/11 i) D*C
j) C′ ./D k) C+D′ l) ones(4)-eye(4)+diag(D)
m) D.∧ 2.*sqrt(B(:,2)′ ) n) E=[A(1:2,:);B(:,1)′ ;zeros(1,4)]′

2) Write the MATLAB commands to generate the following:

i) Linear vector starting from 0 to 20 with a step 0.5. (Use two methods)
ii) Logarithm vector starting from 0.001 to 100 with 50 points.

3) Consider the following complex matrix:


 
2 + j4 3 − j5
X=
1 − j3 j7

i) Enter the matrix X into the MATLAB environment.


ii) Write the MATLAB commands to compute the following and then get the outputs:

a) Magnitude of X. b) Phase angle of X.


c) Conjugate transpose of X. d) Unconjugated transpose of X.
e) Squares of X elements.

4) Use only the MATLAB functions ones, zeros and eye to generate the following matrices:
(Do not use any mathematical operation)

     
1 0 0 0 1 1 0 0 1 0 1 0
i) A = ii) B = iii) C =
0 1 0 0 1 1 0 0 0 1 0 1
     
1 0 0 0 1 0 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 1 1 0
iv) D = 
0
 v) E =   vi) F =  
0 1 0 1 1 1 0 0 1 1 0
0 0 0 0 1 1 0 1 0 0 0 0

1
5) Consider the following polynomials:
a(s) = s5 − 2s4 + 7s3 + 13s2 + 24s + 10
b(s) = 3s2 + 5s + 9
i) Enter the polynomials a(s) and b(s) into the MATLAB environment.
ii) Write the MATLAB commands to perform the following operations:
 
1 −2
a) Evaluate a(s) at −1. (Get the output) b) Evaluate b(s) at A = .
5 3
c) a(s) ∗ b(s). (Get the output) d) a(s)/b(s).

6) Consider the following matrices:


   
1 2 1 2
A = 3 −4 6 , b = −1
  
10 6 18 6
i) Enter the matrices A and b into the MATLAB environment.
ii) Write the MATLAB commands to perform the following operations:
a) Solve the equations Ax = b.
b) Compute the characteristic equation of A and its roots.
c) Compute the norm of b. (Get the output)

7) Write the MATLAB code that plots the following curves on the same graph:
y1 (x) = x3
y2 (x) = 5x2 − 6
where −5 ≤ x ≤ 5. Choose the graph style as red dashed for y1 and blue dash-dot for y2 . Add grid
lines and choose suitable labels for the x- and y-axes.
8) Write the MATLAB code that generates a polar plot of the following equation:
r = cos(2θ)
Use θ = [π/200 to 2π with 400 points on linear scale], add grid lines and choose suitable labels for
the x- and y-axes.
9) Write the MATLAB code that generates a figure consists of 2 × 2 subplots as follows:

y1 (t) = − 5e 0.2t sin(0.5t + 7)
y2 (t) = − 3 cos(0.25t) + 7 sin(4t)
3
y3 (t) = 2e−t + 5t + 0.25t2
y4 (t) = sin(2t) cos(3t + 0.625)
where 0 ≤ t ≤ 20. In each subplot, add grid lines and label the x-axis as “Time (sec.)” and the
y-axis as “Amplitude”. Add the title “Different Time-Variant Signals” into the figure.
10) Write the MATLAB code that generates a 3D plot of the following formula:

2 2
z = 1 + e− x +5y sin(x2 ) cos(y 2 − 10)
where −10 ≤ x ≤ 10 and −6 ≤ y ≤ 6. Add grid lines and choose the suitable labels for the x-, y-
and z-axes.
Prof. Mohamed Hussein Amin & Dr. Abdelrahman Morsi

You might also like