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

14 次查看(过去 30 天)
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.

请先登录,再进行评论。

采纳的回答

Bish Erbas
Bish Erbas 2018-9-24
编辑:Bish Erbas 2018-9-24
Try:
n = 15;
x = 1./(1:n-1);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by