pascal matrix in matlab

To create a pascal matrix in Matlab, you can use the pascal function. This function takes one input argument, which is the size of the matrix. The output is a matrix filled with Pascal's triangle values.

Here's an example code:

main.m
% create a 5x5 pascal matrix
p = pascal(5);
disp(p);
53 chars
4 lines

Output:

main.m
1     1     1     1     1
1     2     3     4     5
1     3     6    10    15
1     4    10    20    35
1     5    15    35    70
130 chars
6 lines

In this example, we create a 5x5 pascal matrix using the pascal function, then display the matrix using the disp function. The output shows the values of the pascal matrix.

gistlibby LogSnag