@Kyle Weaver I recommend 'MATLAB Learning Material' and 'References' for further understanding. % Define the range of t with 450 data points between -4*pi and 4*pi t = % write the linspace command here % Calculate y for each t using the given function: y = sin(t) y = % write the function 'y' command here % Plotting y as a function of t plot(t, y) xlabel('t') ylabel('y') title('Plotting Sine Functions') grid on MATLAB Learning Material: MATLAB Onramp | Self-Paced Online Courses - MATLAB & Simulink (mathworks.com) References Generate linearly spaced vector - MATLAB linspace (mathworks.com) Sine of argument in radians - MATLAB sin (mathworks.com) --------------------------------------------------------------------------------------------------------------------------------------------------- If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback. Professional Interests Technical Services and Consulting Embedded Systems | Firmware Developement | Simulations Electrical and Electronics Engineering Feel free to contact me. Answer from Hassaan on mathworks.com
🌐
Johns Hopkins University
math.jhu.edu › ~shiffman › 370 › help › techdoc › ref › linspace.html
linspace (MATLAB Function Reference)
Description The linspace function generates linearly spaced vectors. It is similar to the colon operator ":", but gives direct control over the number of points. y = linspace(a,b) generates a row vector y of 100 points linearly spaced between a and b.
Discussions

Plotting sine functions using linspace command
Plotting sine functions using linspace command. Learn more about plotting MATLAB More on mathworks.com
🌐 mathworks.com
2
0
February 25, 2024
How do I create a regularly-spaced array of values in MATLAB? - Stack Overflow
How do I make an array that's defined with a start point, an end point, and a total array size? Something like an array that goes from 1 to 10 that's 20 elements long. For example, the array could ... More on stackoverflow.com
🌐 stackoverflow.com
When to use Linspace?
Your signal on the top is aliasing! Note that your frequency is 100hz, so one period is equal to 1/100= 0.01 seconds, or completes 10 cycles every 0.1 seconds (look at the 3rd plot). I generally avoid linspace since I like using my own precision (i.e. t=beginning:precision:ending), and for continuous time I sometimes set precision = (f*10)-1 (so I see 10 points every period). More on reddit.com
🌐 r/matlab
4
1
February 17, 2021
How to use linspace on a matrix
How to use linspace on a matrix. Learn more about matrix, indexing, matlab, vectors, arrays More on mathworks.com
🌐 mathworks.com
2
0
April 17, 2021
🌐
MathWorks
mathworks.com › signal processing toolbox › signal generation, analysis, and preprocessing › waveform generation
Create Uniform and Nonuniform Time Vectors - MATLAB & Simulink
Tcont = linspace(0,3,20001)'; plot(Tcont,gpl(Tcont),tdisc,gpl(tdisc),'o','markersize',5) ... Run the command by entering it in the MATLAB Command Window.
🌐
University of Utah
users.cs.utah.edu › ~germain › PPS › Topics › Matlab › linspace.html
Matlab Function - Linspace
The linspace function allows you, the programmer, to create an instantiated array. You must say what the first number in the array is. You must say what the last number in the array is. You must say how many numbers the array is to hold.
Find elsewhere
🌐
Reddit
reddit.com › r/matlab › when to use linspace?
r/matlab on Reddit: When to use Linspace?
February 17, 2021 -

I'm working with continuous-time (CT) and discrete-time (DT) signal and want to plot them in Matlab.

For 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). I then plot the value of x() against the created t(). The graphs I got were different with different length of my vector generated by linspace and none of them seems correct. (The correct version is using the normal method* of creating vector (t3, x3)).

Code:

f=100;                     %Frequency
t1=linspace(0,1,100);      %From 0 to 1 in 100 steps
t2=linspace(0,1,300);      %From 0 to 1 in 300 steps
t3=0:0.001:1;              %From 0 to 1 and increment by 0,001

x1=cos(2*pi*f*t1);
x2=cos(2*pi*f*t2);
x3=cos(2*pi*f*t3);

subplot(3,1,1);
plot(t1,x1);
subplot(3,1,2);
plot(t2,x2);
subplot(3,1,3);
plot(t3,x3);

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.

Code:

w=linspace(-10*pi,10*pi,1000);
xa=(i*w)./(1+i*w);
figure(1);
subplot(2,1,1);plot(w,abs(xa));grid on;
subplot(2,1,2);plot(w,angle(xa));grid on;

If I generate w by normal method*, the graph still looks the same.

Can someone please explain!

Thanks.

Graphs of (t1, x1) (t2, x2) (t3, x3)
🌐
MathWorks
mathworks.com › matlabcentral › answers › 804726-how-to-use-linspace-on-a-matrix
How to use linspace on a matrix - MATLAB Answers - MATLAB Central
April 17, 2021 - How to use linspace on a matrix. Learn more about matrix, indexing, matlab, vectors, arrays
🌐
GeeksforGeeks
geeksforgeeks.org › software engineering › linearly-spaced-vector-in-matlab
Linearly Spaced Vector in MATLAB - GeeksforGeeks
November 28, 2022 - More clearly, say one wants to divide a domain [1,2] in intervals with 5 points or vectors so, the resultant vector would be [1.0, 1.25, 1.50, 1.75, 2.0]. This new vector is what we call a linearly spaced vector.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1647500-alternative-for-linspace
Alternative for linspace? - MATLAB Answers - MATLAB Central
February 11, 2022 - function [xvals, yvals]=A5fourier(L,nmax,numpoints) %xvals=linspace(-L,L,numpoints); for z=-0.1:0.001:0.1 xvals=z; end yvals=zeros(1,numpoints); for i=1:numpoints for j=1:2:nm...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 238150-what-is-the-difference-between-a-vector-and-using-linspace
What is the difference between a vector and using linspace? - MATLAB Answers - MATLAB Central
August 31, 2015 - The linspace function produces a vector of fixed length (defined by the third argument) between the limits defined by the first two.
🌐
RDocumentation
rdocumentation.org › packages › pracma › versions › 1.9.9 › topics › linspace
linspace function - RDocumentation
linspace(x1, x2, n = 100) x1 · ... be generated · vector containing n points between x1 and x2 inclusive. These functions will generate n linearly spaced points between x1 and x2....
🌐
University of Maryland
terpconnect.umd.edu › ~toh › spectrum › linspace.txt
linspace
LINSPACE Linearly spaced vector. LINSPACE(X1, X2) generates a row vector of 100 linearly equally spaced points between X1 and X2. LINSPACE(X1, X2, N) generates N points between X1 and X2. For N < 2, LINSPACE returns X2.
🌐
Reddit
reddit.com › r/matlab › creating a time vector with linspace
r/matlab on Reddit: Creating a time vector with linspace
July 16, 2020 -

I am trying to use linspace to create a time vector that is equal to length of the number of samples in an array. For example, I have a test with 30000 samples and each was taken 5ms in between As a result, first samples starts at 0, second at 5, third at 10th, and so on. I am trying to use linspace to accomplish this but running into problems. Here is what I am trying to do *test is the array with all the samples*

time = linspace(0, length(test), 5)

I am trying to create a vector that starts at zero and increments by 5 for each sample. All this does is create 5 times that are crazily spaced. I realize that the last variable actually just generate 5 number of points but thats not what I am trying to do as I want the step size to be 5. Any ideas? Thanks so much in advance!

🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.4 Manual
>>> import matplotlib.pyplot as plt >>> N = 8 >>> y = np.zeros(N) >>> x1 = np.linspace(0, 10, N, endpoint=True) >>> x2 = np.linspace(0, 10, N, endpoint=False) >>> plt.plot(x1, y, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.plot(x2, y + 0.5, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.ylim([-0.5, 1]) (-0.5, 1) >>> plt.show()