Question: MATLAB 3. Pascal's Triangle Pascal's triangle is a triangular array containing certain integers, which is named after the French mathematician Blaise Pascal (1623-1662). It is

MATLAB

MATLAB 3. Pascal's Triangle Pascal's triangle is a triangular array containing certainintegers, which is named after the French mathematician Blaise Pascal (1623-1662). Itis known as Pascal's triangle in much of the Western world, although

3. Pascal's Triangle Pascal's triangle is a triangular array containing certain integers, which is named after the French mathematician Blaise Pascal (1623-1662). It is known as Pascal's triangle in much of the Western world, although other mathematicians studied it centuries before him in India, Persia, China, Germany, and Italy. The triangle starts with a 1 on the top row. From there, each entry in a row is equal to the sum of the 2 numbers directly above it. If one of those two numbers does not exist, then a 0 is used, hence the left and right edges of the triangle are composed only of ones. Figure 1 graphically shows how each element in the triangle is created. 2 of 4 Spring 2021 1 1 / 1 12 1 1 3 3 1 1 1+3 1 Figure 1: Summing diagonal elements to create each successive element. MATLAB does not work with triangular-shaped matrices, so you will be creating a so-called left-justified Pascal's triangle, as shown in Figure 2. Column 2 3 4 5 6 7 8 9 1 0 0 0 0 0 0 1 0 Row 1 2 3 4 1 1 OOO 0 0 0 0 0 0 0 0 0 0 2 1 0 1 13 3 1 0 0 0 0 1 4 6 4 1 0 0 0 0 5 6 1 5 10 10 5 1 0 0 0 1 6 15 20 15 6 1 0 0 7 8 1 7 21 35 35 21 7 1 0 9 1 8 28 56 70 56 28 8 1 Figure 2: Left justified Pascal's triangle. You will write a recursive function that determines the value an element a certain row and column in the left-justified Pascal's triangle. This function should have the following function declaration line: 1 function value = pascalsTriangle (row, col) The arguments of pascalsTriangle are the indices of the value you want. Test pascalsTriangle with many different input arguments including: 1 pascalsTriangle (5, 1) 2 pascalsTriangle (6, 4) 3 pascalsTriangle (8, 5) A p-file buildTriangleP.p has been provided that will display your triangle in the centered form. In your published script file display the first 10 rows of your completed Pascal's triangle by passing a handle to your function pascalsTriangle in to the buildTrianglep function as shown below. 1 buildTriangle (@pascalsTriangle, 10)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!