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]$ divided into $n$ equal intervals.

If the number of elements is not specified, it returns a $1\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]$ divided by equal intervals of $m$.

If the interval is not specified, the interval is set to $1$. It is used when the length of the interval is important, not the number of intervals. There may not be a natural number $n$ that satisfies $b=a+n\cdot m$. In this case, the endpoint is not $b$, but the largest number satisfying $a+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