create a time vector from 0-5 in increments of 0.2 in matlab

You can create a time vector from 0-5 in increments of 0.2 using the linspace function in Matlab.

main.m
time = linspace(0, 5, 26);
27 chars
2 lines

This will create a vector time with 26 elements, ranging from 0 to 5 in increments of 0.2. The linspace function automatically generates a row vector of n evenly spaced points between x1 and x2.

Alternatively, you can create the same vector using arithmetic operations and vectorization as follows:

main.m
time = 0:0.2:5;
16 chars
2 lines

This will also create a vector time with 26 elements, ranging from 0 to 5 in increments of 0.2. The : operator creates a row vector of equally spaced values between the starting value, 0, and the ending value, 5, with a step size of 0.2.

gistlibby LogSnag