Subplot(2,1,2) plot(w,angle(xa)) grid on The same problem does not apply whether or not I use linspace or normal method\* to create an array to plot magnitude and phase of a function. y logspace(a,b,n) generates n points between decades 10a and 10b. y logspace(a,b) generates a row vector y of 50 logarithmically spaced points between decades 10a and 10b. Example: To create the row vector having equally spaced elements. n is the number of elements in the row vector. xl is the last element of the row vector. The principal difference is that with the colon operator, you define the interval between successive elements and let the length of the resulting vector vary, and in linspace, you define the length of the vector and the function calculates the interval to fit the length. Especially useful for creating frequency vectors, it is a logarithmic equivalent of linspace and the ':' or colon operator. linspace(xf,xl,n) xf is the first element of the row vector. One is the colon (:) operator, and the other is the linspace function. T1=linspace(0,1,100) %From 0 to 1 in 100 steps There are two principal ways to create vectors in MATLAB. The linspace function allows the programmer to produce an array, matrix, or vector of numbers that are linearly spaced. (The correct version is using the normal method\* of creating vector (t3, x3)). The graphs I got were different with different length of my vector generated by linspace and none of them seems correct.
I then plot the value of x() against the created t(). I'm working with continuous-time (CT) and discrete-time (DT) signal and want to plot them in Matlab.įor CT, when I used the function linspace to create a vector of values and then use that to have a function (t1, x1 and t2, x2).