MATLAB を使用して、周期的なデータを含む時系列のデータ ギャップを埋める方法を探しています (この場合、潮汐周波数に等しい周波数で、半日周期と春/小潮周期の両方)。データ系列には、時間のギャップを埋める人工データの上に重ねたいノイズも含まれています。データには、維持したい特定の傾向があります。理想的には、タイムギャップの両側で記録されたデータを使用する方法を検討しています。
とにかくMatlabでこれを行うことはありますか?
ありがとうございました。
ドナルド・ジョン
MATLAB を使用して、周期的なデータを含む時系列のデータ ギャップを埋める方法を探しています (この場合、潮汐周波数に等しい周波数で、半日周期と春/小潮周期の両方)。データ系列には、時間のギャップを埋める人工データの上に重ねたいノイズも含まれています。データには、維持したい特定の傾向があります。理想的には、タイムギャップの両側で記録されたデータを使用する方法を検討しています。
とにかくMatlabでこれを行うことはありますか?
ありがとうございました。
ドナルド・ジョン
したがって、できることは、モデル関数を「推測」し、最適化ルーチンを使用してそのモデルにデータを適合させることです。次に、残差をよく見て、その残差からノイズを特徴付ける統計を取得します。次に、モデルを適用してノイズを追加します。Matlab コードでは、Ansatz は次のようになります。
t_full = linspace(0,4*pi,500);
t = t_full([1:200, 400:end]);
f = 2;
A = 3;
D = 5;
periodic_signal = A*sin(t*f) + D;
trend = 0.2*t;
noise = randn(size(t));
y = periodic_signal + trend + noise;
% a model for the data -- haha i know the exact model here!
model = @(par, t) par(1)*sin(t*par(2)) + par(3) + par(4)*t;
par0 = [2, 2, 2, 2]; % and i can make a good guess for the parameters
par_opt = nlinfit(t,y, model, par0); % and optimize them
% now from the residuals (data minus model) one can guess noise
% characteristics
residual = y - model(par_opt, t);
% compare residual with "real noise" (should coincide if optimisation
% doesnt fail)
[mean(noise), mean(residual)] % about [0, 0]
[std(noise), std(residual)] % about [1, 1]
missing_data = 201:399;
new_noise = mean(residual) + std(residual)*randn(size(missing_data));
% show what is going on
figure
plot(t,y,'k.')
hold on
plot(t_full, model(par_opt, t_full), 'r-', 'linewidth', 2);
plot(t_full(missing_data), model(par_opt, t_full(missing_data)) + new_noise, 'r.')
legend('data', sprintf('y(t) = %.2f*sin(%.2f*t) + %.2f + %.2f*t + e(t)', par_opt), 'reconstructed data')
次の図が表示されます。