plot the first seven fourier coefficients of a 50hz rectified sine wave in matlab
main.m
% Define the parametersf = 50; % Frequency of the sine wavet = 0:0.0001:0.1; % Time vectorx = abs(sin(2*pi*f*t)); % Rectified sine wave% Compute the Fourier series coefficientsN = 7; % Number of coefficientscoefficients = zeros(1, N);
for n = 1:N
coefficients(n) = integral(@(t) abs(sin(2*pi*f*t)).*cos(2*pi*n*f*t), 0, 1/f) / (1/f); % Fourier coefficient formulaend% Plot the first seven Fourier coefficientsstem(1:N, coefficients);
xlabel('Coefficient Index');
ylabel('Coefficient Value');
title('First Seven Fourier Coefficients of 50Hz Rectified Sine Wave');