0% found this document useful (0 votes)
5 views2 pages

Up&down Sampling

Up and downsampling using MATLAB

Uploaded by

BACHU AKSHITHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Up&down Sampling

Up and downsampling using MATLAB

Uploaded by

BACHU AKSHITHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Upsampling

% Original sequence
x = [1, 2, 3, 4, 5]; % Define the original sequence
L = 3; % Upsampling factor (e.g., 3 times upsampling)

% Upsample the sequence


y = upsample(x, L);
disp(x);
disp(y);

% Generate time indices for plotting


n = 0:length(x)-1; % Indices for original sequence
n_upsampled = linspace(0, length(x)-1, length(y)); % Scaled indices for
upsampled sequence

% Plot the original and upsampled sequences


figure;
subplot(2, 1, 1);
stem(n, x, 'filled');
title('Original Sequence');
xlabel('Time (normalized)');
ylabel('Amplitude');
grid on;

subplot(2, 1, 2);
stem(n_upsampled, y, 'filled');
title(['Upsampled Sequence (Factor = ', num2str(L), ')']);
xlabel('Time (normalized)');
ylabel('Amplitude');
grid on;

Down sampling
% Original sequence
x = [1, 2, 3, 4, 5, 6, 7, 8, 9]; % Define the original sequence
M = 2; % Downsampling factor (e.g., 2 times
downsampling)

% Downsample the sequence


y = downsample(x, M);
disp(x);
disp(y);

% Generate time indices for plotting


n = 0:length(x)-1; % Indices for original sequence
n_downsampled = linspace(0, length(x)-1, length(y)); % Scaled indices for
downsampled sequence
disp(linspace(0, length(x)-1, length(y)))
% Plot the original and downsampled sequences
figure;
subplot(2, 1, 1);
stem(n, x, 'filled');
title('Original Sequence');
xlabel('Time (normalized)');
ylabel('Amplitude');
grid on;

subplot(2, 1, 2);
stem(n_downsampled, y, 'filled');
title(['Downsampled Sequence (Factor = ', num2str(M), ')']);
xlabel('Time (normalized)');
ylabel('Amplitude');
grid on;

You might also like