フィルターのクリア

Expected a string scalar or character vector for the parameter name

25 ビュー (過去 30 日間)
Sonia
Sonia 2023 年 12 月 17 日
回答済み: Brahmadev 2023 年 12 月 27 日
% Set parameters
f_c = 0.002; % Hz, sinusoidal signal frequency
theta_range = [-pi, pi]; % radians, phase range
T = 1000; % seconds, signal duration
A = sqrt(2); % amplitude for unit average energy
No = 1; % power spectral density of noise
M = 500; % number of realizations for averaging
% Generate time vector
t = linspace(0, T, 10001);
% Autocorrelation function initialization
R_x_tau = zeros(1, length(t));
% Loop for M realizations
for i = 1:M
% Generate random phase
theta = theta_range(randi(2))*pi;
% Generate sinusoidal signal
x_t = A*cos(2*pi*f_c*t + theta);
% Generate white Gaussian noise
noise = randn(size(t)) * sqrt(No/2);
% Generate signal with noise
x_t_noise = x_t + noise;
end
% Loop for different tau values
for tau = 1:length(t)
% Calculate product for current tau
product_tau = x_t_noise(tau + 1:end) .* x_t_noise(1:end-tau);
% Calculate and accumulate average product
R_x_tau(tau) = R_x_tau(tau) + 1/M * mean(product_tau);
end
% Calculate theoretical autocorrelation function
R_x_theo = 2*A^2*cos(2*pi*f_c*t) + 2*No*delta(t);%%%%%%%%%%%%%%%%%%%%ERROR
delta requires RF PCB Toolbox.
% Plot results
figure;
subplot(211);
plot(t, x_t_noise);
xlabel('Time (s)');
ylabel('Signal with Noise');
title('Sinusoidal Signal with White Gaussian Noise');
subplot(212);
plot(t, R_x_tau);
hold on;
plot(t, R_x_theo);
legend('Estimated Autocorrelation', 'Theoretical Autocorrelation');
xlabel('Time (s)');
ylabel('Autocorrelation Function');
title('Autocorrelation Function of Signal with Noise');
  3 件のコメント
Sonia
Sonia 2023 年 12 月 17 日
How can it be an example value for delta?

サインインしてコメントする。

回答 (1 件)

Brahmadev
Brahmadev 2023 年 12 月 27 日
Hi @Sonia,
I understand that you would like to calculate the autocorrelation using the Dirac Delta function, you can use the 'dirac' function. Please refer to the documentation below for more information.
Hope this helps in resolving your query!

カテゴリ

Help Center および File ExchangeParametric Spectral Estimation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by