Continuous to Discrete time signal

9 次查看(过去 30 天)
Damir Kadyrzhan
Damir Kadyrzhan 2020-11-10
回答: Jon 2020-11-10
Hello,
I have 2 frequencies combined together to one graph to form continuous time signal. How can I turn it to discrete time signal? I am struggling with combining 2 frequencies to discrete time.
I have written data for discrete time, but is there a way to turn it into one?
t = 0:0.001:1.8
Fq1 = 1
Fq2 = 6
x_t = sin(2*pi*Fq1*t) + sin(2*pi*Fq2*t)
plot (t, x_t, 'LineWidth', 2)
hold on
Fs1 = 10 % 2hz * 5
Fs2 = 60 % 12hz * 5
Ts1 = 1/Fs1 % Sampling period Ts1 = 1/10hz
Ts2 = 1/Fs2 % Sampling period Ts = 1/60hz
T2 = 1/Fq2 % The period 2
T1 = 1/Fq1 % The period 1
N1 = T1/Ts1 % Number of samples per period
N2 = T2/Ts2
n2 = 0:1:2*N2 - 1
n1 = 0:1:2*N1 - 1 % 20 samples range
nTs1 = n1 * Ts1 % Sampling interval (samples range multiplied by sampling period to have a range of data for graph)
nTs2 = n2 * Ts2
x_n1 = sin(2*pi*3*nTs1) + sin(2*pi*3*nTs2)% Discrete signal formula and calculation
stem(nTs1, x_n1) % doesn't work
hold on

回答(1 个)

Jon
Jon 2020-11-10
You should just evaluate and save your values x_t once
Then to get your discrete samples (assuming the discrete sample interval is a multiple, m, of your original sampling interval ) you can use something like
k = 1:n:length(x_t)
stem(t(k),x_t(k))

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by