Basics
Completion requirements
8. Equally Spaced Arrays
Typing every entry is time consuming for long arrays. If the points are equally spaced this isn't necessary. An alternative method is to use the colon notation [first_value : interval : last_value]
If the interval is left out MATLAB uses a default interval of 1.
Another way of specifying an equally-spaced array is to use the linspace command. This allows you to specify the number of data points, but not the interval to be used. The notation is:
linspace(first_value, last_value, number_of_values)
If the data for number_of_values is not specified, it is taken as 100.
>> a = 1:2:10
a =
1 3 5 7 9
>>
Another way of specifying an equally-spaced array is to use the linspace command. This allows you to specify the number of data points, but not the interval to be used. The notation is:
linspace(first_value, last_value, number_of_values)
If the data for number_of_values is not specified, it is taken as 100.