Help Formatting Vector To Not Include Starting Point

15 views (last 30 days)
I am trying to create a vector of linearly spaced numbers, but not including zero (but I need to start from zero).. Say I wanted five linearly spaced numbers from zero to two (and including two), but not including zero, how would I go about this? As far as I am aware, linspace always includes the starting point, right? Thank you!

Accepted Answer

Stephen23
Stephen23 on 6 Jun 2018
N = 5;
vec = linspace(0,2,N+1);
vec = vec(2:N);
  2 Comments
Bailey Smith
Bailey Smith on 6 Jun 2018
I still need it to include the end point, just not the starting point. This only gives me 4 points instead of 5.
Bailey Smith
Bailey Smith on 6 Jun 2018
Nevermind. I see you missed the +1 on the second vector. Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!