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

 Réponse acceptée

v = 1 ./ (1:10)

6 commentaires

No, that only gives me a value of 10. I need to create an array with values 1, 1/2, 1/3, 1/4 up to 1/10.
Rik
Rik le 21 Juil 2019
Have you tried this code? It should do what you want.
"No, that only gives me a value of 10. I need to create an array with values 1, 1/2, 1/3, 1/4 up to 1/10."
It worked for me:
>> v = 1 ./ (1:10)
v =
1 0.5 0.33333 0.25 0.2 0.16667 0.14286 0.125 0.11111 0.1
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]
>>
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...
Sorry, I was mistaking with spaces between characters..:/ all answers work. Thank you everyone!!

Connectez-vous pour commenter.

Plus de réponses (1)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by