How to get a geometric sequence?

27 ビュー (過去 30 日間)
Grace
Grace 2014 年 10 月 2 日
編集済み: Yokesh 2017 年 6 月 27 日
Hi, I have
tao=1000;
v=0.9;
T1=0.01;
I want to have a geometric sequence T, where T1=T2=T3...=T1000 ( since tao=1000)
The first 100 T will be equal to T1,
The second 100 T which starts from T101 until T200= v*T1
The third 100 T ( from T201 until T300 = v*v*T1)
The fourth 100 T (from T301 till T400 = v*v*v*T1)
and so on.
How am I going to get the sequence? Thanks in advance.
  1 件のコメント
Yokesh
Yokesh 2017 年 6 月 27 日
編集済み: Yokesh 2017 年 6 月 27 日
A = r.^(1:n);
This creates matrix A with geometric sequence with a ratio 'r'

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

回答 (2 件)

SK
SK 2014 年 10 月 2 日
Use the .^ operator and matrix multiplication
T = v.^(0:9) * T1;
T = ones(100,1)*T;
T = T(:);
Alternatively (maybe faster)
T = v.^(0:9) * T1;
T = T(ones(1,100), :);
T = T(:);

the cyclist
the cyclist 2014 年 10 月 2 日
It was not perfectly clear to me what you needed to leave as a variable, and what is a constant. But, this should get you started.
v=0.9;
T1=0.01;
T = T1*ones(100,10);
v_vector = v.^(0:9);
T = bsxfun(@times,T,v_vector)
T = reshape(T,1,1000)

カテゴリ

Help Center および File ExchangePole and Zero Locations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by