Have you ever wondered what the formula for that thing that looks like a sine wave, but is really just half circles? Well, take a look below for the Matlab code of how to generate and plot such a signal with a particular frequency. If you need help translating to another programming or graphing language, just let me know.
Also, a handy feature of this code is the ability to only plot the first N periods. Take a look!
Fs = 100; % Sampling frequency T = 1/Fs; L = 1000; % Number of samples t = (0:L-1)*T; % Time vector fs = 1; % Frequency of signal. A = 1; % Amplitude of signal. % Half-circle waveform: r = 1/(fs*4); y = (A/r)*((2*(mod(t,r*4) == mod(t,2*r)) - 1).*sqrt(r^2 - (mod(t,2*r)-r).^2)); % Regular sine waveform: y2 = A*sin(2*pi*fs*t); % Plot the waveforms. numPeriods = 3; tEnd = round(numPeriods/(T*fs)); plot(t(1:tEnd),y(1:tEnd),t(1:tEnd),y2(1:tEnd))