显示 更早的评论
Hi
I have a simple query.
Suppose i have a signal s = randn(1,10), if I want to add delay 100ms to this signal, what should i do?
I heard about upsampling the signal and then adding zeros, but can you help me with an example code
s = randn(1,8);
delay = 100ms;
s1 = upsample(s,?);
s_delay = [how many zeros, s1]?
Is that approach right?
采纳的回答
It is not possible to add a delay to a signal unless you know what the sampling frequency is.
12 个评论
Okay, here is my actual prob
load handel.mat;
hfile = 'handel.wav';
[y,Fs] = wavread(hfile); % this will give me a broadband signal with 73113 samples and Fs = 8192;
I want to add a delay of 1.3 ms to this 'y'. How do I do that?
I assume I need to pad fix((Fs*1.3e-3)) zeros in the front, is that right?
In this case
fix(Fs*1.3e-3)% =10, so i need to pad 10 zeros in the beginning
x = vertcat(zeros(10,1), y(1:length(y)-10));
Is 'x' the 1.3ms delayed signal?
But I gather there is another method...wherein, we upsample the signal and low pass filter it...can you please help me with that?
Cheers
Express the intervals as fractions.
1.3 ms is 13/10000 .
Fs is 1/8192
solve as a fraction:
13/10000 = x/8192
which gives x = 6656/625
Cross-check: (1/10000)*(13*625) = 6656*(1/8192) gives 13/16 = 13/16 which is true.
Therefore, the signal must be upsampled by a factor of 6656, after which 1.3 ms will correspond to 13*625 = 8125 zeros.
Adding fix((Fs*1.3e-3)) zeros will *not* get you a 1.3 ms delay: it will get you a 1.22 ms delay, which is not a good enough approximation for sound processing purposes.
Agh, I understand it now. Thank you very much.
Please allow me to ask one more query.
1. The signal in the above quoted case 'y' has 73113 samples.
If I use
x = upsample(y,6656), I get the error
'Maximum variable size allowed by the program is exceeded'
What to do about that?
2. Fs is 8192, not 1/8192. Is it a mistake you typed in the 3rd statement?
3. Of the topic, how can we find the sampling frequency of a signal of the form s = randn(1,1000)?
Please help me as I am struggling with this concept for a couple of days.
Thanks a lot
2. Yes, sorry, the sampling interval is 1/Fs, 1/8192
1. I am mildly surprised that upsample said that the maximum variable size allowed by the program was exceeded, as the result would only be 3.6+ gigabytes, which would fit in to 32 bit memory if only everything else was out of the way. I would have thus expected "out of memory" instead of maximum variable size. In any case, Yup, it's too big for you to compute using upsample() unless you switch to the 64 bit version of MATLAB.
What to do about it? The usual way is to use a fractional delay filter instead of using upsample.
3. There is no sampling frequency for a signal defined by its samples. If someone from another of our departments were to send me a data file with 1000 samples, I would not know whether it was a measurement off of one of our attosecond (1E-18 second) lasers, or a measurement that had been done once a week for about 21 years.
Yup. But in your "actual prob" from your first comment, you do not have a random signal and you know the Fs from the wavread() command, so the question of sampling frequency for randn(1,1000) is not relevant to that situation.
Hi again,
Bear with me this one time.
1. Yeah, Fs for randn is not relevant. Sorry.
2. I read the document on design.fracdelay, but could not understand how to upsample a sequence or add delay to 'y', in the above stated context. I have not worked on filters or used the command.
Can you just give me an example of how to use the command to upsample or add delay?
I can start my coding once I can do that.
Please.
and thanks for the method, it will be a big relief for me, if I can get this going today!
Cheers
For a signal having 1000 samples, on my machine, the signal can be upsampled by a max of '99999'.
entiredelay = 0.0013 * Fs;
wholesamplesdelay = floor(entiredelay);
fracdelaysamples = entiredelay - wholesamplesdelay;
d = fdesign.fracdelay(fracdelaysamples);
H = design(d, 'lagrange', 'FilterStructure', 'farrowfd');
I have not researched to see how you would use H. Whatever output you get from using it needs to be pre-padded with wholesamplesdelay 0's.
upsampling would not come in to it. upsampling is an alternative method.
It would not surprise me if there is an fft() based method of implementing the delay, perhaps by adjusting the phase.
Okay so here is how I used
entiredelay = 0.0013 * Fs;
wholesamplesdelay = floor(entiredelay);
fracdelaysamples = entiredelay - wholesamplesdelay;
d = fdesign.fracdelay(fracdelaysamples);
H = design(d, 'lagrange', 'FilterStructure', 'farrowfd');
y1 = filter(H,y);
y1 = vertcat(zeros(wholesampledelay,1),y1);
is that right?
Looks plausible to within my limited filter knowledge.
Hmm, okay, let me see how this goes.... Thank you very much. Good day
Hi again, Morning!
Just realized that we may use the translation property of Fourier transform, but unable to figure out how.
if h(x) = ƒ(x − x0), then H(w)= e^{-2 π i x0 ω }F(ω)
Can you help me with this approach?
Cheers
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
