MATLAB: Cosine Wave understanding Problem

beginnerfhss

Hi, yeah this is probably a lame question : the following code is from fhss by farhat masood on matlab central
t=[0:2*pi/119:2*pi] ; % Creating 60 samples for one cosine
How is it 60 samples for one cosine ? and what is the freq of the cosine ? also where did 119 come from ?
later used in code as : c=cos(t);

Best Answer

Suppose you used [0:1/2:1] . How many values would be in the vector? Answer: 3, namely 0, 1/2, and 1. And for [0:1/3:1]? Four values, 0, 1/3, 2/3, 1.
Thus [0:2*pi/119:2*pi] will create a vector of 120 total values including the endpoints.
120 is 2 * 60, which suggests that in context the nyquist frequency is being taken in to account.
You might find it easier to understand
linspace(0, 2*pi, 120)