How can I solve this confidence level error?
Afficher commentaires plus anciens
I was trying to plot data of power spectra of pressure, u, v. However, the confidence level keep plotting strange.
I think my confidence level is missing something, or reason that I didn't apply code 'butter'.
Attached file is on .txt, original file is on .dat
clear all
close all
clc
data_uv = load('D5_SN111.dat'); % u, v data
data_pressure = load('D5_SN111(1).dat'); % pressure data
u = data_uv(:, 7); % u 성분 (7번째 열)
v = data_uv(:, 8); % v 성분 (8번째 열)
% D5_SN111(1).dat: year month day hour minute sec pressure
pressure = data_pressure(:, 7); % pressure data
pressure = fillmissing(pressure, 'linear');
u = fillmissing(u, 'linear');
v = fillmissing(v, 'linear');
WINDOW = 1024 * 2;
NOVERLAP = 512 * 2;
NFFT = 1024 * 2;
Fs = 1; % (1 sample/hour)
confcen = 10; %
conf_level = 100; %
%% pressure data PSD
figure;
[pxx_pressure, f_pressure, Pxxc_pressure] = pwelch(pressure, WINDOW, NOVERLAP, NFFT, Fs, 'ConfidenceLevel', 0.95);
loglog(f_pressure, pxx_pressure, 'k'); % 파워 스펙트럼 밀도 그래프
hold on;
confup = Pxxc_pressure(conf_level, 2) ./ pxx_pressure(conf_level) * confcen;
confdn = Pxxc_pressure(conf_level, 1) ./ pxx_pressure(conf_level) * confcen;
loglog([f_pressure(conf_level), f_pressure(conf_level)], [confdn, confup], 'r', 'LineWidth', 1.5);
title('Power spectra of bottom pressure at D5');
xlabel('Frequency (Hz)');
ylabel('Power/frequency (dbar^2/Hz)');
grid on;
legend('PSD', '95% Confidence Interval');
hold off;
%% u data's PSD
figure;
[pxx_u, f_u, Pxxc_u] = pwelch(u, WINDOW, NOVERLAP, NFFT, Fs, 'ConfidenceLevel', 0.95);
loglog(f_u, pxx_u, 'b');
hold on;
confup = Pxxc_u(conf_level, 2) ./ pxx_u(conf_level) * confcen;
confdn = Pxxc_u(conf_level, 1) ./ pxx_u(conf_level) * confcen;
loglog([f_u(conf_level), f_u(conf_level)], [confdn, confup], 'r', 'LineWidth', 1.5);
title('Power spectra of U at D5');
xlabel('Frequency (Hz)');
ylabel('Power/frequency ((cm/s)^2/Hz)');
grid on;
legend('PSD', '95% Confidence Interval');
hold off;
%%v data's PSD
figure;
[pxx_v, f_v, Pxxc_v] = pwelch(v, WINDOW, NOVERLAP, NFFT, Fs, 'ConfidenceLevel', 0.95);
loglog(f_v, pxx_v, 'g');
hold on;
confup = Pxxc_v(conf_level, 2) ./ pxx_v(conf_level) * confcen;
confdn = Pxxc_v(conf_level, 1) ./ pxx_v(conf_level) * confcen;
loglog([f_v(conf_level), f_v(conf_level)], [confdn, confup], 'r', 'LineWidth', 1.5);
title('Power spectra of V at D5');
xlabel('Frequency (Hz)');
ylabel('Power/frequency ((cm/s)^2/Hz)');
grid on;
legend('PSD', '95% Confidence Interval');
hold off;

and, this is what I got.
However, I was trying to get such data.

I have no idea what I'm missing with.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Distribution Plots 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!





