how to write a geometric series in command window

74 visualizzazioni (ultimi 30 giorni)
How do I write a vector that follows the geometric form: 1, 3, 6, 9...
  10 Commenti
Torsten
Torsten il 8 Set 2022
But note that you need 1 as first term followed by 99 terms of the form 1/(3*i).
1./(3:3:300) gives 100 terms of the form 1/(3*i).

Accedi per commentare.

Risposte (2)

KSSV
KSSV il 8 Set 2022
a = 1 ;
r = 2 ;
n = 0:9 ;
gp = a*r.^n
gp = 1×10
1 2 4 8 16 32 64 128 256 512
  4 Commenti
Sami Ahmed
Sami Ahmed il 8 Set 2022
i really dont know, my assignment is asking to create the vector: 1, 3, 6, 9
Torsten
Torsten il 8 Set 2022
This is not a geometric sequence.
For a geometric sequence, the quotient of two subsequent members of the sequence must be constant:
a(n+1)/a(n) = q = const. for every n.
In your case:
a2/a1 = 3
a3/a4 = 2
a5/a4 = 1.5
so the quotient is always different.

Accedi per commentare.


David Hill
David Hill il 8 Set 2022
sum(1./[1,3:3:297])
ans = 2.7258

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by