main.m523 chars23 lines
In this code, we first define the parameters such as the frequency of the sine wave (50 Hz), the sampling frequency (fs), and create the time vector. We then generate the rectified half-wave sine wave, perform the Fourier transform on it, calculate the frequencies of the Fourier coefficients, and compute the amplitudes of the first seven coefficients. Finally, we display the frequencies and amplitudes.
gistlibby LogSnag