Matlab 4. The elements of the symmetric Pascal matrix are obtained from: Py (1-1
ID: 3905598 • Letter: M
Question
Matlab
4. The elements of the symmetric Pascal matrix are obtained from: Py (1-1)IG-1)! Where jis the row number and j is the column number of the element. Use nested loops to create an 9x9 symmetric Pascal matrix. Display the completed matrix in the command windoW. 5. Use nested loops and conditional statements to create a 4x7 matrix in which the value of each element is equal to the square root of the sum of the element's indices unless the element is in an even-numbered column or row. Instead, the value of an element in an even-numbered column or row is equal to the sum of the element's indices squared. (The indices of an element in a matrix are the row number and column number of the element.) Display the completed matrix in the command window.Explanation / Answer
Code for Question 4:
=======
format rat
pascalMat = zeros(9, 9);
for i = 1:9
for j = 1:9
pascalMat(i, j) = factorial(i + j - 2) / (factorial(i-1) * factorial(j-1));
end
end
pascalMat
======
output
pascalMat =
Columns 1 through 7:
1 1 1 1 1 1 1
1 2 3 4 5 6 7
1 3 6 10 15 21 28
1 4 10 20 35 56 84
1 5 15 35 70 126 210
1 6 21 56 126 252 462
1 7 28 84 210 462 924
1 8 36 120 330 792 1716
1 9 45 165 495 1287 3003
Columns 8 and 9:
1 1
8 9
36 45
120 165
330 495
792 1287
1716 3003
3432 6435
6435 12870
===================================================
Code for Question 5
format short
M = zeros(4, 7);
for i = 1:4
for j = 1:7
if rem(i, 2) == 0 || rem(j, 2) == 0 %even numbered row / col
M(i, j) = sqrt( i + j);
else
M(i, j) = i^2 + j^2;
end
end
end
M
=====
output
=====
M =
2.0000 1.7321 10.0000 2.2361 26.0000 2.6458 50.0000
1.7321 2.0000 2.2361 2.4495 2.6458 2.8284 3.0000
10.0000 2.2361 18.0000 2.6458 34.0000 3.0000 58.0000
2.2361 2.4495 2.6458 2.8284 3.0000 3.1623 3.3166
?
========================
Please do rate the answer if it helped. Thank you