Using "nchoosek(n,k)", create a row vector containing all the binomial coefficients for n=4 and display this vector. Repeat for n=10
5 views (last 30 days)
Show older comments
I have tried applying "v=1:4" & then "A=nchoosek(v,3)" as well as "A=nchoosek(v,4)". However, not to sure what I'm looking for
2 Comments
James Tursa
on 23 Mar 2017
What have you done so far? Please make an attempt and then ask specific questions about where you are having problems with your code. Then we can help you.
James Tursa
on 23 Mar 2017
Edited: James Tursa
on 23 Mar 2017
The instructions say that n=4, and n is the first argument in nchoosek(n,k). So I would expect that you would be using nchoosek(4,k). Then it is just a matter of what k values to use, and how to form everything into a row vector. If n=4, do you know what are all the valid values for k to get the binomial coefficients? And do you know how to form a row vector out of a bunch of numbers?
Answers (1)
Arvind Narayanan
on 28 Mar 2017
Edited: Arvind Narayanan
on 28 Mar 2017
According to the binomial theorem, the coefficient of every term of a polynomial (x+y)^n can be represented as
nCk*x^(n-k)*y^k
Now, I understand you want to make a row vector with the coefficients of the polynomial for n=4 and n=10 respectively. You can use something like this:
A=[];
n=4;
% n=10;
for i=0:1:n
A=[A,nchoosek(n,i)];
end
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!