logo

How to Create Equally Spaced Row Vectors in MATLAB 📂Programing

How to Create Equally Spaced Row Vectors in MATLAB

Method

  • linspace(a,b,n): Returns a row vector of [a,b][a,b] divided into nn equal intervals.

If the number of elements is not specified, it returns a 1×1001\times 100 vector. It is used when the number of intervals is important, not the length of the intervals.

  • a: m :b : Returns a row vector of [a,b][a,b] divided by equal intervals of mm.

If the interval is not specified, the interval is set to 11. It is used when the length of the interval is important, not the number of intervals. There may not be a natural number nn that satisfies b=a+nmb=a+n\cdot m. In this case, the endpoint is not bb, but the largest number satisfying a+nma+n\cdot m.

x1=linspace(1,10,10)
x2=linspace(1,10)
x3=linspace(5,55,2^5)

y1=1:3
y2=1:1/13:2
y3=3:1/7:7

2019-10-0817;03;17\_.png

2019-10-0817;04;11\_.png

In other languages