Assignment
Assignment
Faculty of Engineering
Department of Electrical and Computer Engineering
EE 201- Structured Computer Programming
Assignment - 1
Date: 25/05/2023 Sections: B10 & B90 Last Date to Submit: 01/06/2023
Note: Submit the Assignment as hard copy at my office or during your
EE201 Lecture time
Q1. Write a MATLAB program to make such a pattern like right angle triangle
given below.
Sample execution:
Enter the Number of rows = 5
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Q2. Write a MATLAB program that plots the following signals in the same figure
as follows:
y=x
10
Spaced Points
Continuous Data
5
y
0
0 1 2 3 4 5 6 7 8 9 10
x
f = sin(10t)
1
Sine Wave
0.5
0
f
-0.5
-1
0 1 2 3 4 5 6
t
(Or)
The following equation draws a circle with a center at the origin, where r is the
radius.
0<angle<2*pi
x=r*cos(angle)
y=r*sin(angle)
Then plot 10 circles using a for loop where the radius varies from 1 cm to
10 cm.
Circle with center at the origin
10
y -2
-4
-6
-8
-10
-10 -8 -6 -4 -2 0 2 4 6 8 10
x
When the radius is odd, plot the circles with blue solid line, when the radius is
even, plot it with red dashed line. Use switch case as conditional command.
Q3. Execute the following commands in MATLAB Command window and explain
the result of execution?
If x= [ 2 3 4 8 10 0 -2]
1) x(mod(x,2)= =0)=5*x(mod(x,2)= =0)
2) x(mod(x,2)= =0)=10
3) x(x>3)=5
4) z=x(x<=0)
Q4. Write the MATLAB program for the following sample execution.