Plotting a sum with a variable
25 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Jos (10584)
2014-5-3
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-')
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!