Search code examples
matlabvector

Create vector of form [101, 1001, 10001, ...]


I want to create a vector with 7 elements which has the form

[101, 1001, 10001, ...] 

I can't figure out how to do this only using a:d:b and linspace, without manually inputting the values.

I can't determine the mathematical pattern, just that obviously there is an additional 0 in between each number.

So how would I generate this vector without the use of loops and only the use of a:d:b or linspace?


Solution

  • Your series is actually one added to the powers of 10 and hence:

    req = 1 + 10.^[2:n+1];   %where n is the total length