Matlab problem, please provide help in Matlab code. The Pascal triangle can be d
ID: 3815923 • Letter: M
Question
Matlab problem, please provide help in Matlab code.
The Pascal triangle can be displayed as elements in a lower-triangular matrix where the element i j is the binomial coefficient i1 j 1 . Use the nchoosek command in this regard. Create the Pascal triangle having 7 rows
Here is a picture of the problem
The Pascal triangle can be displayed as elements in a lower-triangular matrix where the element ij is the binomial coefficient I). Use the nchoosek command in this regard. Create the Pascal triangle having 7 rows.Explanation / Answer
Matlab code:
M = zeros(7,7);
for i = 1:7
for j = 1:i
M(i,j) = nchoosek(i-1,j-1);
end
end
M
Sample Output: