clc;
close all;
clear;
workspace;
format short g;
format compact;
fprintf('Beginning to run %s.m ...\n', mfilename);
dt = 1/1024;
x = 0 : dt : 1.2;
omega = 5 : 30
for k = 1 : length(omega)
thisOmega = omega(k);
thisPeriod = 1 / thisOmega;
fprintf('Omega = %.1f. Period = %.4f\n', thisOmega, thisPeriod);
lastIndex = find(x <= 6 * thisPeriod, 1, 'last');
thisx = x(1 : lastIndex);
y = sin(2 * pi * thisOmega * thisx);
plot(thisx, y, '-');
legendStrings{k} = sprintf('Omega = %.1f', thisOmega);
hold on;
drawnow;
end
grid on;
legend(legendStrings);
fontSize = 20
title('6 periods of several frequencies', 'FontSize', fontSize);
ylabel('Amplitude', 'FontSize', fontSize);
xlabel('Time in Seconds', 'FontSize', fontSize);
g = gcf;
g.WindowState = 'maximized';
fprintf('Done running %s.m.\n', mfilename);