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

18 ビュー (過去 30 日間)
MAK
MAK 2018 年 9 月 23 日
コメント済み: Arun Singh 2022 年 9 月 7 日
How I can code this vector x=[1; 1/2;1/3; ......;1/(n-1)] n=15 ?
  6 件のコメント
Stephen23
Stephen23 2018 年 9 月 24 日
編集済み: Stephen23 2018 年 9 月 24 日
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 2022 年 9 月 7 日
for n= 1:50
fprintf("1/"+n+", ")
end
Try this

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

採用された回答

Bish Erbas
Bish Erbas 2018 年 9 月 24 日
編集済み: Bish Erbas 2018 年 9 月 24 日
Try:
n = 15;
x = 1./(1:n-1);
  1 件のコメント
Yamazaki
Yamazaki 2020 年 9 月 20 日
Thats the best answer I have looked for

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by