How can I make a vector divide 1 by increasing numbers?

2 次查看(过去 30 天)
how can I generate a vector with values 1,1/2,1/3...1/10?

采纳的回答

Guillaume
Guillaume 2019-7-21
v = 1 ./ (1:10)
  6 个评论
Guillaume
Guillaume 2019-7-21
No, that only gives me a value of 10.
You could at the very least try the answers you are given, otherwise we're not going to go very far...
Seba.V
Seba.V 2019-7-21
Sorry, I was mistaking with spaces between characters..:/ all answers work. Thank you everyone!!

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2019-7-21
i = 1;
while i <= 10
v(i) = 1./i;
i = i + 1;
end

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by