Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

broadband signal, randn, Matlab query

Status
Not open for further replies.

Praveen_C

Newbie level 6
Joined
Jan 17, 2012
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
New Zealand
Activity points
1,401
Hi

I need a small clarification

Can we treat

s = sin(2*pi*100*randn(1,101).*[0:1/100:1]) as a broad band signal? My idea is that, since its fft "plot(abs(fft(s)))" has a value at every frequency, it might be considered as broadband. But I am not sure. Please advice.

It is of the form s(t) = sin(2*pi*fs*t), and t=0:1/fs:1

Cheers
 

It is not a random signal... It is a signal composed by sinewaves with randomly chosen frequencies. A better broad-band signal would be "randn". Moreover, you could low/band/high pass filter it to obtain the desired signal bandwidth.
 
Okay, if I use s=randn(1,100)

Then at a later stage, I need to add a delay in time. It is given by x(t) = s(t-D). D is the delay in terms of distance.

For example, D=(sqrt(10)-sqrt(9))/340, which is a very low value.

How do I add that delay to

s= randn(1,100)

Please advice

Thanks
 

For a sampled random signal the delay can be only integers of the sampling period unless you use filtering (some filters can implement fractional delay). In your case this might be too much complication.

A multi-tone signal with random phases and random frequencies can approximate a wide-band random signal the only problem is that it is periodic and it causes tones in the spectrum. Therefore you need to consider what properties are important to your experiment.
 

Well, what would be the solution in this case?

1. If I find Ns=D*Fs, then can I use Ns to delay the signal 's=randn(1,100)' by Ns samples? But I do not know how to do that.

2. Or else, can you suggest me any example of time domain broad band signal, so that i can include delay in there?

Thanks

---------- Post added at 12:28 ---------- Previous post was at 12:26 ----------

Well, what would be the solution in this case?

1. If I find Ns=D*Fs, then can I use Ns to delay the signal 's=randn(1,100)' by Ns samples? But I do not know how to do that.

2. Or else, can you suggest me any example of time domain broad band signal, so that i can include delay in there?

Thanks

---------- Post added at 12:31 ---------- Previous post was at 12:28 ----------

Or else, can we treat

p=randn(1,100);
t=0:1/100:1;
s = p.*t;

's' to be a broadband signal? Agh, just stuck around trying to describe how a broadband signal would be, and how to add delay to it....

Please advice

Thanks a lot
 

Matlab uses sampled data vectors. A vector a=[0 1 2 3 4 5 6 7] could be the result of sampling at 1Hz or 1GHz. So, let's say that you want to delay "a" (sampled at 1Hz) by 100ms you need to first upsample a by 10 times (so that you have a 10Hz samples vector): a10=[0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 ... 7 7 7 7 7 7 7 7 7 7]; (you should also low-pass filter it) then you can delay a10 by 1 sample by adding one 0: a10d=[0 a10];
Your a signal could be any signal, for instance a=randn(1,8);
A simple code is:
Code:
a=rand(1,8);
plot(0:10:70,a)
hold on
a10=a(ones(1,10),:);
a10=a10(:).';
plot(0:79,a10,'r')
Read the code carefully and experiment for yourself...
 
Last edited:
I am almost near, but allow me to ask more.

We have a = [0 1 2 3 4 5 6 7]. the size 0f the vector = 8. How do we know the Fs of this signal?

Now we up sample the signal. Why did you choose up sample f = 10, Is it because f = 1/100 ms = 10? Or at choice is it a large value?

Let me put it in the code and ask you....

a = rand(1,8) % size of the vector = 8, initial signal...how can we find its Fs

plot(0:10:80,a) % is giving the error X and Y must be the same length

a10=upsample(10,a); % that can pad 9 zeros in between each sample, now the size if the signal is 80

a10d=[0,a10] % Why did you choose to add one zero(is that something related to 100ms?).

Please help me out today. I will really appreciate it. I got stuck for the last 3 days.

cheers
 

We have a = [0 1 2 3 4 5 6 7]. the size 0f the vector = 8. How do we know the Fs of this signal?
The Fs of the signal can be any. You must know it beforehand. In this case it was 1Hz.
Why did you choose up sample f = 10, Is it because f = 1/100 ms = 10? Or at choice is it a large value?
Yes. I said that, for example, you need to delay your signal by 100ms therefore I up-sampled by 10.
a = rand(1,8) % size of the vector = 8, initial signal...how can we find its Fs
As I said, you need to know something about your data vector.
plot(0:10:80,a) % is giving the error X and Y must be the same length
It was a typo that I fixed above.
a10=upsample(10,a); % that can pad 9 zeros in between each sample, now the size if the signal is 80
Correct.
a10d=[0,a10] % Why did you choose to add one zero(is that something related to 100ms?).
Because it is one sample at 10Hz, that is 100ms. The effect of the 0 is to delay the signal by 100ms.
 
Please bear one more question, before I can start my code. Please....and thanks.

I am now using an audio file as my signal source.

load handel.mat;
hfile = 'handel.wav';
[a,Fs] = wavread(hfile);

So now, 'a' is the broadband signal having 73113 samples and Fs = 8192.

Now I want to add 1.3 ms delay to this sequence.

See if I am right.
upsample f = 1/1.3ms = 769.2Hz OR f = Fs(1/1.3ms) = 8192*769.2 = 6.3013e6(which seems not correct for me)
ad = upsample(a, ?)
ad_1,3 = [0,ad];

Also, the size of the signal(in the previous case, has changed from 80 to 81), but shouldn't we have 80 samples even for the delayed signal? Do we need to delete the last sample?

Please bear this once and I can start my coding. Thanks very much for your guidance.
 

If Fs=8192Hz, the sampling period is Ts=122.1us. If you delay your signal by 11 samples Td=11*Ts=1.3428ms you will almost achieve the delay you need. Do you need exactly 1.3ms? If not, you do not need to up-sample!!

the size of the signal(in the previous case, has changed from 80 to 81), but shouldn't we have 80 samples even for the delayed signal? Do we need to delete the last sample?
It's up to you you can keep the 81st sample (I would, most likely) or discard it.
 
Thank you so very much for the guidance. I will start writing the code. I now assume that I will have to pad fix(Fs*Td) zeros in the beginning to get the delayed signal.

But when would be the up sampling procedure come into picture? I was assuming to do it that way(proposed by my professor).

Thank you very much for your support.

---------- Post added at 14:54 ---------- Previous post was at 14:10 ----------

clear all;
clc
load handel.mat
hfile = 'handel.wav';
[y,Fs] = wavread(hfile);
s = repmat([1;3],1,5);
x = vertcat([0:4],zeros(1,5));
d_m = sqrt(sum((x-s).^2));
a_m = 1./d_m;
x1 = 0.3162*y;
x2 = 0.333*(vertcat(y(1:length(y)-3), zeros(3,1)));
x3 = 0.3162*y;
x4 = 0.2774*(vertcat(zeros(10,1), y(1:length(y)-10)));
x5 = 0.2357*(vertcat(zeros(26,1), y(1:length(y)-26)));
S = [x1,x2,x3,x4,x5];
R = (S*S');

I system is out of memory it seems. Is there any other solution to get the correlation matrix 'R'?

Whoops, I think need to write R = S'*S;
 

Hi again

This is another alternative I had worked out. Please let me know if it is right! Sounded like what your were mentioning in the beginning of the discussion.

We have a signal

[y,Fs]=wavread('handel.wav');

The signal has 73113 samples and Fs = 8192

We want to add a delay(Td) of 1.3ms = 13/10000.

So

x = Fs*Td = 8192*(13/10000)=13*512/625 = 6656/625

Cross checking: 13*625/10000 = 6656/8192 which implies 13/16=13/16 which satisfies the above maths.

So can we gather that, to add 1.3ms delay to 'y', we up sample it by 6656, and pad 13*625=8125 zeros in the beginning.

Is this approach correct?

If yes, 'y' is a signal vector having 73113 samples. If I try

x=upsample(y,6656)

I will have to get a signal vector of size 73113*6556, for which I get an error saying 'Maximum variable size allowed by the program is exceeded'.

I assume it would be better to use fractional delay filter instead of upsample. Can you help how to use this command in our context?

Please advice. Thanks for your support.
 

I system is out of memory it seems. Is there any other solution to get the correlation matrix 'R'?
Whoops, I think need to write R = S'*S;
I am not very good at optimizing code. Maybe someone else can give you a hint on this.

---------- Post added at 19:40 ---------- Previous post was at 19:24 ----------

So can we gather that, to add 1.3ms delay to 'y', we up sample it by 6656, and pad 13*625=8125 zeros in the beginning.
Is this approach correct?
Yes, it is correct but it creates a BIG vector... do you need to use the whole signal? Can you split the signal into chunks? I also just realized that you could apply the delay in frequency domain using the translation property of the Fourier Transform: if h(x) = ƒ(x − x0), then  H(w)= e^{-2 π i x0 ω }F(ω). Just a consideration...
I assume it would be better to use fractional delay filter instead of upsample. Can you help how to use this command in our context?
For this you need to ask a DSP expert (I am actually an analog designer who likes to fiddle with DSP...).
 
Last edited:

Okay, these are the two methods I tried yesterday.

load handel.mat;
[y,Fs]=wavread('handel.wav'); % 'y' is an audio signal vector with 73113 samples and Fs = 8192.
Now I want to add a delay of 1.3ms

1. delay = 1.3e-3*Fs;
whole_delay = floor(delay);
frac_delay = delay - whole_delay;
d = fdesign.fracdelay(frac_delay);
H = design(d,'lagrange','FilterStructure','farrowfd');
y1 = filter(H,y);
y1 = vertcat(zeros(whole_delay,1),y1); % padding 10 zeros in the beginning
S = [ vertcat(y,zeros(whole_delay),1) ; y1]; % Both the signals y and y1 together as a matrix for later processing

2. y=y(10000:20000); % I have to consider chunks here, or else I will take a signal
y = randn(1,100) % smaller length vector for upsampling purpose, in thisn case, I assume an Fs = 48KHz(appropriate for sound signals)
y1 = upsample(y,6556); % pad 6555 zeros between each sample
y1 = vertcat(zeros(8125,1),y1);
S = [vertcat(y,zeros(73113*6556),1)) ; y1];

Which do you think is an intelligent approach?

3. I think the Fourier transform property sounds appealing. But can you please, give an example code for that? I am not well aware of using FT. Will appreciate your help in the commands in the context of 'y'.

Thanks a ton
 

I would have to try them but I believe the first method is the most effective.

3. I think the Fourier transform property sounds appealing. But can you please, give an example code for that? I am not well aware of using FT. Will appreciate your help in the commands in the context of 'y'.
You just need to multiply the FFT of your signal by the complex exponential function that represents the delay and than apply an IFFT to bring it back to the time-domain.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top