code for ido x2

mail@pastecode.io avatar
unknown
plain_text
8 days ago
597 B
3
Indexable
Never
%% Q2 Section A - (B) Second Approach

% Length of the signal x_2[n]
N2 = 1024;

% Consider the variance of noise w_2
sigma_w2 = sqrt(0.51);

% Generate white noise w_2[n]
w2 = sigma_w2 * randn(1, N2);

% Initialize x_2[n] - according to first approach detailed in document
x2 = zeros(1, N2);
x2(1) = randn(1,1); % as Var(x2) = 1, sigma_x2 is 1 - it's normal dist.

% Generate x_2[n]
for n = 2:N2
    x2(n) = 0.7 * x2(n-1) + w2(n);
end

% Plot x_2[n] entire signal - via matlab's builtin functions
figure;
plot(x2);
title('Signal x_2[n]');
xlabel('n');
ylabel('x_2[n]');
Leave a Comment