% Octave commands for plotting simple signals

% all plots are from time 0 to 1s
t=0:0.001:1;

% Prepare the figure for plotting
figure(1); 
set (1, "defaultlinelinewidth", 3);
xlabel("time [seconds]");
ylabel("signal strength [volts]");
axis([0 1 -2 2]);
hold on

% Plot of sine wave with different frequency and amplitudes
plot(t, 1*sin(2*pi*1*t + 0), 'b');
plot(t, 1*sin(2*pi*2*t + 0), 'r');
plot(t, 1.5*sin(2*pi*3*t + 0), 'g');

% Clear the previous figure, preparing again for new plots
clf
axis([0 1 -2 2]);
xlabel("time [seconds]");
ylabel("signal strength [volts]");
hold on

% Plot a sine wave with different phase
plot(t, 1*sin(2*pi*1*t + 0), 'b');
plot(t, 1*sin(2*pi*1*t + pi/4), 'r');
plot(t, 1*sin(2*pi*1*t + pi/2), 'g');
plot(t, 1*sin(2*pi*1*t + 3*pi/4), 'y');
plot(t, 1*sin(2*pi*1*t + pi), 'c');

% Clear and prepare the figure (all in one line)
clf; axis([0 1 -2 2]); xlabel("time [seconds]"); ylabel("signal strength [volts]"); hold on;

% Plot two sine waves and then the summation of the two
plot(t, sin(2*pi*2*t), 'k');
plot(t, (1/3)*sin(2*pi*2*3*t), 'k');
plot(t, sin(2*pi*2*t) + (1/3)*sin(2*pi*2*3*t), 'b');

% Clear and prepare the figure (all in one line)
clf; axis([0 1 -2 2]); xlabel("time [seconds]"); ylabel("signal strength [volts]"); hold on;

% Plot the sum of two sine waves, then multiple by pi/4
plot(t, sin(2*pi*2*t) + (1/3)*sin(2*pi*2*3*t), 'b');
plot(t, (4/pi)*(sin(2*pi*2*t) + (1/3)*sin(2*pi*2*3*t)), 'r');

% Clear and prepare the figure (all in one line)
clf; axis([0 1 -2 2]); xlabel("time [seconds]"); ylabel("signal strength [volts]"); hold on;

% Plot the summation of sine waves with different number of components
% Last plot is close approximation of digital signal
plot(t, (4/pi)*( sin(2*pi*2*t) ), 'b');
plot(t, (4/pi)*( sin(2*pi*2*t) + (1/3)*sin(2*pi*2*3*t) ), 'r');
plot(t, (4/pi)*( sin(2*pi*2*t) + (1/3)*sin(2*pi*2*3*t) + (1/5)*sin(2*pi*2*5*t) ), 'g');
plot(t, (4/pi)*( sin(2*pi*2*t) + (1/3)*sin(2*pi*2*3*t) + (1/5)*sin(2*pi*2*5*t) + (1/7)*sin(2*pi*2*7*t) ), 'c');
plot(t, (4/pi)*( sin(2*pi*2*t) + (1/3)*sin(2*pi*2*3*t) + (1/5)*sin(2*pi*2*5*t) + (1/7)*sin(2*pi*2*7*t) + (1/9)*sin(2*pi*2*9*t)  + (1/11)*sin(2*pi*2*11*t) + (1/13)*sin(2*pi*2*13*t)  + (1/15)*sin(2*pi*2*15*t)  + (1/17)*sin(2*pi*2*17*t) + (1/19)*sin(2*pi*2*19*t)  + (1/21)*sin(2*pi*2*21*t) + (1/23)*sin(2*pi*2*23*t) + (1/25)*sin(2*pi*2*25*t) + (1/27)*sin(2*pi*2*27*t) + (1/29)*sin(2*pi*2*29*t) + (1/31)*sin(2*pi*2*31*t) + (1/33)*sin(2*pi*2*33*t) + (1/35)*sin(2*pi*2*35*t) + (1/37)*sin(2*pi*2*37*t) + (1/39)*sin(2*pi*2*39*t) + (1/41)*sin(2*pi*2*41*t) + (1/43)*sin(2*pi*2*43*t) + (1/45)*sin(2*pi*2*45*t) + (1/47)*sin(2*pi*2*47*t) + (1/49)*sin(2*pi*2*49*t) + (1/51)*sin(2*pi*2*51*t) + (1/53)*sin(2*pi*2*53*t) + (1/55)*sin(2*pi*2*55*t) + (1/57)*sin(2*pi*2*57*t) + (1/59)*sin(2*pi*2*59*t) ), 'k');

% Keep extending the last plot, e.g. 1/61, 1/63, to get a more accurate representation of the digital signal
