create an half-wave sine in time and in frequency with fourier coefficients in matlab
main.m
% Time domain - half-wave sine signalfs = 1000; % Sampling frequencyt = 0:1/fs:1; % Time vector from 0 to 1 secondx = sin(2*pi*5*t).*(sin(2*pi*5*t) > 0);
% Frequency domain - Fourier coefficientsN = 50; % Number of Fourier coefficientscoefficients = zeros(1, N);
for n = 1:N
coefficients(n) = integral(@(t) sin(2*pi*5*t).*(sin(2*pi*5*t) > 0).*exp(-1i*2*pi*n*t), 0, 1);
enddisp(coefficients);