增加信号频率

发布于 2024-10-31 04:13:14 字数 1152 浏览 0 评论 0原文

大家好,

我回去并使用了 resample (来自信号处理工具箱)和repmat,但我注意到某些值的行与采样率不同,请参阅下面的图像链接。请注意,顶部图像的 rows 值显示为 1000,底部图像显示 rows = 1008。当我更改 resample 和 repmat (freq_new) 的值但仅针对某些值时,会发生这种情况。我怎样才能正确解决这个问题?我可以删除 1000 之后的所有内容,但我不确定这是一个错误还是 resample/repmat 的工作方式。 PS:使用matlab/octave

http://dl.dropbox.com/u/6576402/questions/rows_ Different.png

这里是我用来测试这个的测试代码

%resample_repmat signal
clear all, clf
Fs = 1000; % Sampling rate
Ts = 1/Fs; %sampling interval
t=0:Ts:1-Ts; %sampling period

freq_orig=1;
y=sin(2*pi*t*freq_orig)'; %gives a short wave

freq_new=9;
y2=resample(y,1,freq_new); %resample matrix
y3=repmat (y2,freq_new,1); %replicate matrix

[r_orig,c_orig] = size(y) %get orig number of rows and cols
[r_new,c_new] = size(y3) %get new number of rows and cols

subplot(2,1,1),plot(y),title('Orginal signal')
title(['rows=',num2str(r_orig),' cols=',num2str(c_orig)])
subplot(2,1,2),plot(y3),title('New signal')
title(['rows=',num2str(r_new),' cols=',num2str(c_new)])

Greetings All

I went back and used resample (from the signal processing toolbox) and repmat, but I'm noticing that on some of the values the rows aren't the same as the sample rate, see image link below. notice the top image value for rows says 1000 and the bottom image says rows = 1008. This happens when I change the values of resample and repmat (freq_new) but only for certain values. How can I fix this correctly? I could just delete everything after 1000 but I'm not sure if this is a bug or just the way resample/repmat works. PS: using matlab/octave

http://dl.dropbox.com/u/6576402/questions/rows_different.png

Here's the test code I used to test this

%resample_repmat signal
clear all, clf
Fs = 1000; % Sampling rate
Ts = 1/Fs; %sampling interval
t=0:Ts:1-Ts; %sampling period

freq_orig=1;
y=sin(2*pi*t*freq_orig)'; %gives a short wave

freq_new=9;
y2=resample(y,1,freq_new); %resample matrix
y3=repmat (y2,freq_new,1); %replicate matrix

[r_orig,c_orig] = size(y) %get orig number of rows and cols
[r_new,c_new] = size(y3) %get new number of rows and cols

subplot(2,1,1),plot(y),title('Orginal signal')
title(['rows=',num2str(r_orig),' cols=',num2str(c_orig)])
subplot(2,1,2),plot(y3),title('New signal')
title(['rows=',num2str(r_new),' cols=',num2str(c_new)])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

邮友 2024-11-07 04:13:14

由于您的原始信号有 1000 个样本长,因此以短 9 倍的周期对其进行重采样将在一个周期内提供 111.11111... 个样本。 Matlab 将这个数字向上舍入为 112。想一想。如果您的周期有 111 个样本长,则完整波将有 999 个样本长。因为它有 112 个样本长,所以当您将其中 9 个样本放在一起时,它们会产生一个 1008 个样本长的信号。没有办法让它变成 1000,因为你正在处理离散时间。代码是正确的,它做了它应该做的事情。从物理上来说,没有办法将任何事物的 9 个相同循环精确地拟合到 1000 个离散样本中。我希望这有帮助。

或者,您可以尝试首先重复初始波形九次,然后重新采样。您的周期不会完全相同,但它们可以很好地适应 1000 个样本。

我希望这有帮助=)

Since your original signal is 1000 samples long, resampling it with a period 9 times shorter would give you 111.11111... samples in one cycle. Matlab rounds this number up to 112. Think about it. If your cycles were 111 samples long, your complete wave would be 999 samples long. Because it's 112 samples long, when you put nine of them together they produce a 1008-samples-long signal. There is no way to make it 1000, because you're dealing with discrete times. The code is right, it does what it's supposed to. There is physically no way to fit precisely 9 identical cycles of anything into 1000 discrete samples. I hope this helps.

Alternatively, you can try first repeating your initial wave nine times and then resampling it. Your cycles would not be identical, but they would fit nicely into the 1000 samples.

I hope this helps = )

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文