Hi everyone. I would like to plot something of the form:
sum( (factorial(k) / (factorial(i)*factorial(k-i)), i=1..k)
for different values of k, say, for k=1,2,..,10 in a single graph.
Does anyone know the syntax how to do that? I greatly appreciate your answers! Thanks! D

 채택된 답변

Jos (10584)
Jos (10584) 2014년 5월 3일

0 개 추천

Creat a function and use arrayfun:
fh = @(k) sum(factorial(k) ./ factorial(1:k) .* factorial(k-(1:k))) % function handle
x = 1:5
y = arrayfun(fh, x) % apply function to a list of values
plot(x, y ,'bo-')

추가 답변 (1개)

Dimitri
Dimitri 2014년 5월 3일
편집: Dimitri 2014년 5월 3일

0 개 추천

Thank Jos, everything makes sense now!

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2014년 5월 3일

편집:

2014년 5월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by