MATLAB Answers

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

43 views (last 30 days)
Seba.V
Seba.V on 21 Jul 2019
Commented: Seba.V on 21 Jul 2019
how can I generate a vector with values 1,1/2,1/3...1/10?

  0 Comments

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 21 Jul 2019
v = 1 ./ (1:10)

  6 Comments

Show 3 older comments
madhan ravi
madhan ravi on 21 Jul 2019
Worked for me as well:
>> sym ( 1 ./ (1:10) )
ans =
[ 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10]
>>
Guillaume
Guillaume on 21 Jul 2019
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 on 21 Jul 2019
Sorry, I was mistaking with spaces between characters..:/ all answers work. Thank you everyone!!

Sign in to comment.

More Answers (1)

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

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by