Using "nchoosek(n,k)", create a row vector containing all the binomial coefficients for n=4 and display this vector. Repeat for n=10

19 次查看(过去 30 天)
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 个评论
James Tursa
James Tursa 2017-3-23
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
James Tursa 2017-3-23
编辑:James Tursa 2017-3-23
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?

请先登录,再进行评论。

回答(1 个)

Arvind Narayanan
Arvind Narayanan 2017-3-28
编辑:Arvind Narayanan 2017-3-28
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
Refer this: Binomial Theorem

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by