how to make a Series?

162 ビュー (過去 30 日間)
sama
sama 2015 年 4 月 10 日
コメント済み: sama 2015 年 4 月 14 日
Hello, I am trying to create a series like this:
X(n)=-(sqrt(n)-Sqrt(n-1))x(1)-(sqrt(n-1)-sqrt(n-2))x(2)-(sqrt(n-2)-sqrt(n-3))x(3)+......+1/(1+exp(-an))
So, if n=1:
x(1)=1/(1+exp(-a))
if n=2:
x(2)=-(sqrt(2)-1)x(1)+1/(1+exp(-2a))
and so on. I have never worked with series at MATLAB. I can find any way to create the series, however, i am wondering if there are some specific rule.
Thanks a lot.

採用された回答

Roger Stafford
Roger Stafford 2015 年 4 月 10 日
x = zeros(N,1);
for n = 1:N
x(n) = sum(-(sqrt(n:-1:2)-sqrt(n-1:-1:1)).*x(1:n-1))+1/(+exp(-a*n));
end
  2 件のコメント
Roger Stafford
Roger Stafford 2015 年 4 月 10 日
It would save excessive square roots to write
x = zeros(N,1);
s = sqrt(1:N);
for n = 1:N
x(n) = sum((s(n-1:-1:1)-s(n:-1:2)).*x(1:n-1))+1/(+exp(-a*n));
end
sama
sama 2015 年 4 月 14 日
Thanks a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTime Series についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by