Problem in plotting a summation

조회 수: 1 (최근 30일)
Henry
Henry 2014년 9월 9일
편집: Evan 2014년 9월 9일
Hello everybody.
I'm having a serious problem in plotting a summation. My problem is the following: my function is (e^x)/x that is a multiplicative factor, outside the series, who multiplies the following series:
Sum for k = 1 to N of (k!)/(x^k)
I tried with
plot(plot::Sum(factorial(k)/2^k, k = 1..10)),
but the result is:
plot(plot::Sum(factorial(k)/2^k, k = 1..10)), plot(plot::Sum(factorial(k)/2^k, k = 1..10)), | Error: Unexpected MATLAB operator.
I don't understand what's the problem. I found this on your site but it doesn't work. Clearly, I wrote only the series without the multiplicative factor, to have an idea, but .. I don't know!!
Thanks to anyone will answer me!
  댓글 수: 1
Joseph Cheng
Joseph Cheng 2014년 9월 9일
편집: Joseph Cheng 2014년 9월 9일
well plot(plot::Sum(factorial(k)/2^k, k = 1..10)) isn't in matlab syntax for starters.
**edit/update: this is with Mupad notation, not the first thing i think of when looking at matlab code.
which would be
plot(plot::Sum(k!/2^k, k = 1..10))
if you're looking to plot in MuPad.

댓글을 달려면 로그인하십시오.

답변 (1개)

Evan
Evan 2014년 9월 9일
편집: Evan 2014년 9월 9일
Try out the cumsum function. Also it's worth noting that all the functions/operators you need (factorial, ./, .^, etc.) can all handle arrays, meaning you don't really need to worry about looping. You can create a single array that is each term of your cumulatively summed series using the factorial function and the element-by-element versions of the division and power operators, then plot that.
EDIT It looks like you're using MuPAD for this. My above explanation is for solving your problem using the standard MATLAB language.

카테고리

Help CenterFile Exchange에서 Get Started with MuPAD에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by