Time Scaling In Discrete Time Signals

45 次查看(过去 30 天)
enrique128
enrique128 2020-11-13
回答: tuan 2024-5-18
Hello everyone. I want to apply time scaling property to my signal. It is hard for me to apply for the signals especially like x[4n], x[2n], x[1/3n]. I know there must be mod calculation because the values should be integer but i could not write the code can someone help me please?
n=[-2 -1 0 1 2 3 4];
x=[3 1 0 4 6 2 9];

回答(2 个)

Setsuna Yuuki.
Setsuna Yuuki. 2020-11-13
n=[-2 -1 0 1 2 3 4];
x=[3 1 0 4 6 2 9];
stem(n,x);hold on; %original
n2 = 4*n;
stem(n2,x); %x4
n3 = 2*n;
stem(n3,x);%x2
to x[1/3n] I don't know :(
  3 个评论
Foysal Ahmmed
Foysal Ahmmed 2021-7-9
okey. but the figure should include 0 amplitude for the rest of the integer sample value. Again we cant find x[n/2] this way. because they includes fraction sample n=1.5 .
Luke Ramel
Luke Ramel 2023-3-10
this is wrong, since if we have a multiplier of 2 to the time (n) the x-axis values should be divided by 2 since we are scaling time.

请先登录,再进行评论。


tuan
tuan 2024-5-18
x = [3 1 0 4 6 2 9];
n=-2:4
% Time scaling factors
factors = 2; % efficiency
for factor = factors
% Determine scaling type (compression or expansion)
if factor > 1
scaling_type = 'Compression';
else
scaling_type = 'Expansion';
end
% Time-scaled indices based on scaling type
if factor > 1
% Compression: select indices where n is a multiple of factor
indices = find(mod(n, factor) == 0);
n_scaled = n(indices);
x_scaled = x(indices);
else
% Expansion: replicate and interpolate for integer multiples of factor/n
n_scaled = n / factor;
x_scaled = zeros(size(n));
for i = 1:length(n_scaled)
% Find the closest integer in n for the current n_scaled(i)
[~, closest_idx] = min(abs(n - n_scaled(i)));
x_scaled(i) = x(closest_idx);
end
end
% Plot original and time-scaled signals
figure(1)
stem(n, x);
title('Original')
xlabel('n');
ylabel('Amplitude');
axis([-5,5,0,10])
figure(2)
stem(n_scaled, x_scaled);
xlabel('n');
ylabel('Amplitude');
title('Time Scaling of Discrete-Time Signal');
axis([-5,5,0,10])
end

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by