Department of Mathematics
Second Stage
Advanced Programming
Assignment #1
1. Write a MatLab program (use for loop and if…else) to create a 4 × 4 matrix
such that the upper elements of the main diagonal all are 4 , the lower
elements of the diagonal are 2 and the elements of the main diagonal are 1.
2. Write a MatLab program (use for loop and if…else) to create a 5 × 5 matrix
such that the elements of both main diagonal and the second diagonal are 0
and other elements are 1.
3. By using function, for loop, and if, write a MatLab program to replace row
one by row three in a 3 × 3 matrix.
4. Write a MatLab program to calculate the following
10
(i + j2 )
5
∑∑
j=1 i
i=1
5. Write a MatLab program to calculate the following
5 5
∏∑i ∗ j
i=1 j=1
6. By using function and for loop write a MatLab program to give the
following output
Department of Mathematics
Second Stage
Advanced Programming
Assignment #1
7. Write a MatLab program to give the following output.(use for loop)
8. Write a MatLab program to give the following output.(use for loop)