how I can code this vector x=[1; 1/2;1/3; ......;1/(n-1)] n=15 ?

14 vues (au cours des 30 derniers jours)
MAK
MAK le 23 Sep 2018
Commenté : Arun Singh le 7 Sep 2022
How I can code this vector x=[1; 1/2;1/3; ......;1/(n-1)] n=15 ?
  6 commentaires
Stephen23
Stephen23 le 24 Sep 2018
Modifié(e) : Stephen23 le 24 Sep 2018
n = 15;
v = zeros(n-1,1);
for k = 1:n-1
v(k) = 1/k;
end
But Bish Erbas's answer is preferred.
Arun Singh
Arun Singh le 7 Sep 2022
for n= 1:50
fprintf("1/"+n+", ")
end
Try this

Connectez-vous pour commenter.

Réponse acceptée

Bish Erbas
Bish Erbas le 24 Sep 2018
Modifié(e) : Bish Erbas le 24 Sep 2018
Try:
n = 15;
x = 1./(1:n-1);
  1 commentaire
Yamazaki
Yamazaki le 20 Sep 2020
Thats the best answer I have looked for

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by