User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 397,132 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,590 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser:

Pascal's Triangle

Join Date: Jan 2007
Posts: 1
Reputation: Maddy1987 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Maddy1987 Maddy1987 is offline Offline
Newbie Poster

Solution Pascal's Triangle

  #1  
Jan 12th, 2007





Coefficients in the expansion of (x+y)^n form a pattern which is useful for small values of n. It is known as Pascal's triangle.

n Pascal's triangle
1 1 1
2 1 2 1
3 1 3 3 1
4 1 4 6 4 1
5 1 5 10 10 5 1

Write a Matlab script to calculate and display this expression in the form of the triangle for the first 10 values of n. Use the sprintf command to display in a suitable format such as that shown above.





% A Program for Pascal's Triangle

if nargin ~=2
n=1:10;
s=4;
end

if n<55
a= n/10;
x=0;
y=0;
x2=0;
w=1;


hold on;

for m = 1:n-1
x = x2-a/2;
y = y-a/2*sqrt(2);
w = 1;

x2 = x;

for l = 1:m
x = x+a;
w = nchoosek(m,1);

end
end

else clf;
text(-0.2,0.5,' FontSize',23);
end;

hold off;
axis square;
axis equal;
axis off;


I had tried the question but i am not getting through it can any1 help me out in this problem.
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 3:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC