clear;
close all;
clc;
pkg load io;

% sample frequency (Hz)
fps = 30;  
                              
%Load the data inside Octave from our first code                     
data = load("dataRGB");
greenchannel = data(:,3);
n = data(:,3);

%Numerization of the values
greenchannel_avg = mean(greenchannel);
greenchannel_std = std(greenchannel);
greenchannel_normalized = (greenchannel - greenchannel_avg)/greenchannel_std;

%Fast Fourier Transform
y = fft(greenchannel_normalized);

%number of samples
n = length(greenchannel_normalized); 
        
% frequency range

fr = (0:n-1)*(fps/n);     
power = abs(y).^2/n;

%New representation of the RGB channels
figure(1)
plot(fr, y,'linewidth',1)
ylim([-80 80])
xlim([0.75 4])

%Frequency representation
figure(2)
plot(fr, power,'linewidth',1);    
xlabel('Frequency')
ylabel('Power')
ylim([0 10])
xlim([0.75 4])