이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
upsampling and adding delay to a sequence
조회 수: 2 (최근 30일)
이전 댓글 표시
PChoppala
2012년 1월 18일
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?
채택된 답변
Walter Roberson
2012년 1월 19일
It is not possible to add a delay to a signal unless you know what the sampling frequency is.
댓글 수: 12
PChoppala
2012년 1월 19일
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
Walter Roberson
2012년 1월 19일
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.
PChoppala
2012년 1월 19일
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
Walter Roberson
2012년 1월 19일
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.
Walter Roberson
2012년 1월 19일
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.
PChoppala
2012년 1월 19일
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
PChoppala
2012년 1월 19일
For a signal having 1000 samples, on my machine, the signal can be upsampled by a max of '99999'.
Walter Roberson
2012년 1월 19일
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.
PChoppala
2012년 1월 19일
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?
PChoppala
2012년 1월 19일
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Filter Analysis에 대해 자세히 알아보기
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)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)