How do I generate a vector that has 10000 terms?

I have tried generating a vector variable that is supposed to have the assigned variables 1, 1/2, 1/3, 1/4, 1/5... 1/10,000. It is supposed to be a sequence of 10,000 terms. I have tried using start values and nElements but i keep on getting an error.

 Accepted Answer

I assume you mean ‘assigned values’, not ‘assigned variables’. This is one way to create your vector:
v = 1./(1:10000);
To get any element of it (in this case the 10th element):
V10 = v(10);
If I misunderstood you and you really did mean variables, that is another problem altogether.

1 Comment

yes I meant values, thank you so much. I can not believe it was that simple.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 23 Feb 2014

Commented:

on 23 Feb 2014

Community Treasure Hunt

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

Start Hunting!