Help writting a simple code!

조회 수: 13 (최근 30일)
Hossein sadri
Hossein sadri 2011년 6월 29일
I'm trying to make a Simulink model consisting of a clock (as a source) and a MATLAB function that calculates the following:
Y=exp(t) * sigma(n=1:inf)[n * exp(n*t)]
Can anybody help me write the code?

답변 (5개)

Paulo Silva
Paulo Silva 2011년 6월 29일
MATLAB Fcn
exp(u)*sum([1:10].* exp([1:10].*u)) %not infinite sum but close enough

C.J. Harris
C.J. Harris 2011년 6월 29일
You won't be able to write an infinite series directly. You will either have to use an approximation, or only calculate the sum for the first 'n' elements.

Walter Roberson
Walter Roberson 2011년 6월 29일
If and only if t is less than 0,
Y = exp(2*t)/(exp(t)-1)^2
That is, sum(n*exp(n*t), n = 1 .. infinity) is exp(t)/(exp(t)-1)^2
If t is 0 or greater, the sum is infinite, as you are adding together numbers that increase infinitely.

Hossein sadri
Hossein sadri 2011년 6월 30일
tnx for the answers....and what should i do when i want to do same thing with sigma(n^2*exp(u))?im encountering the error matrix must be squer using [1:10]^2....
  댓글 수: 2
Paulo Silva
Paulo Silva 2011년 6월 30일
[1:10].^2
Walter Roberson
Walter Roberson 2011년 6월 30일
n.^2 instead of n^2
But n^2*exp(u) has the same problem I described above of having an infinite value unless u is negative.

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


amey
amey 2011년 7월 1일
n=1:1:100; y=exp(0.4)*(n.*exp(0.4*n)); tot=0; for i=1:100; tot=tot+y(i); end disp(tot);
  댓글 수: 2
amey
amey 2011년 7월 1일
u = 0.4 ; % assumed
n=1:1:100; % only first 100 terms taken
Paulo Silva
Paulo Silva 2011년 7월 1일
is there another question for us?

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

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by