0
$\begingroup$

I start learning to use Matlab. And I don't know how to create vectors:

1) $1,1/2,1/3,1/4....$

2) $0, 1,2, 2/3, 3/4...$

$\endgroup$
1
$\begingroup$

You cannot create infinitely long vectors in MATLAB (or any other programming language that I am aware of). Note that the computer needs to be able to represent all the elements in that vector in its memory, and that memory is finite.

You could represent a truncated version of the vector as follows:

n = 10; % Make this number (almost) as large as you like
vectorOne = 1./(1:n);
vectorTwo = [0 1 2 2/3 3/4]; % I'm not sure how your series continues
vectorThree = [0 1 2 (2:n-1)./(3:n)];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.