Where is the data?
Afficher commentaires plus anciens
howdy again,
I am plotting the fourier amplitude spectrum for the mauna loa data yet when I run the code, the plot is empty. is it an axes problem? and if so, how do I fix it so that the x axis is still in 10^nth hertz.
% Load the data
filename = 'maunaloa_weekly.csv';
data = readtable(filename, 'ReadVariableNames', false, 'Delimiter', ',');
variableNames = {'Date', 'Values'};
% Assign variable names to the table
data.Properties.VariableNames(1:2) = variableNames;
% Convert the dates to datetime format
dates = datetime(data.Date, 'Format', 'dd/MM/yyyy');
Values = data.Values;
% Create a time vector using datetime
time_vector = dates;
% Plot the data
figure;
subplot(2, 1, 1);
plot(dates, Values, 'LineWidth', 2);
title('Maunaloa Weekly Data');
xlabel('Time');
ylabel('Floating Point Values');
% Fourier analysis plot
subplot(2, 1, 2);
% Time interval between data points
dt = days(7); % Weekly data
% Perform FFT
N = length(Values);
Fs = 1/days(dt); % Sampling frequency
frequencies = Fs*(0:(N/2))/N;
fft_values = fft(Values);
amplitudes = 2/N * abs(fft_values(1:N/2+1));
% Plot the amplitude spectrum with log scale on x-axis
semilogx(frequencies, amplitudes, 'LineWidth', 2);
title('Fourier Amplitude Spectrum');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
2 commentaires
the cyclist
le 1 Fév 2024
Can you upload the maunaloa_weekly.csv file? You can use the paper clip icon in the INSERT section of the toolbar.
Kenzie
le 1 Fév 2024
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Title dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
