Sign in

username:

password:



Not a member?

Search matlab



Search tips

Subscribe to matlab



matlab by Keywords

Atanh | Autocorrelation | Bandpass Filter | C++ | Conv | Database | Deconv | Excel | FFT | Filter | Filtering | FIR | Fourier Transfrom | FSK | Gaussian Noise | Haykin | IFFT | Image | Java | LFSR | LMS | LPC | MEX | OFDM | QPSK | Radix | Random | Sampling | Segmentation | Simulink | Visual Basic | Waveform | Wavelet

Sponsor

NEW! TMS320C6474: 3x the performance. 1/3 the cost. Three 1 GHz cores on 1 chip.

Discussion Groups

Discussion Groups | Matlab DSP | Convolution and Filtering

Technical discussion about Matlab and issues related to Digital Signal Processing.

  

Post a new Thread

Convolution and Filtering - icpower2000 - Jan 11 8:22:49 2007



Hi to all:

 I have this program. My question is at the end of this program below.

clf;
h=[3 2 1 -2 1 0 -4 0 3];
x=[1 -2 3 -4 3 2 1];
y=conv(h,x);
n=0:14;
subplot(2,1,1);
stem(n,y);
xlabel('Time index n');ylabel('Amplitude');
title('Output Obtained by Convolution');grid;
x1=[x zeros(1,8)];
y1=filter(h,1,x1);
subplot(2,1,2);
stem(n,y1);
xlabel('Time index n');ylabel('Amplitude');
title('Output Generated by Filtering');grid;

Question 1: How do I determine the correct size of n?
Question 2: In x1=[x zeros(1,a)], what is the value of "a" in relation
to n,h and x? How do I compute "a"?

Thank you...I am new in DSP using Matlab.


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Convolution and Filtering - heidar mhr - Jan 15 7:41:24 2007

when you use stem(n,y) or plot(n,y), the size of the two arguments n and y has to be
equal. In your program, y is a 1X15 array so n has to have the same size (0-14). similarly,
when you want to use stem(n,y1), y1 has to has a size of 1X15. But if you filter x which has a
size of 1X7, the result (y1) would also have a size of 1X7 thus when you want to plot the
result with respect to n the program will give you an error. That is why you add 8 zeros to x
so the size of x is now equal to 1X(7+8)=1X15 which is equal to size of n and then you can plot
it.

I hope I was clear
----- Original Message ----
From: icpower2000 <i...@yahoo.com>
To: m...@yahoogroups.com
Sent: Wednesday, January 10, 2007 5:46:17 PM
Subject: [matlab] Convolution and Filtering

Hi to all:

I have this program. My question is at the end of this program below.

clf;
h=[3 2 1 -2 1 0 -4 0 3];
x=[1 -2 3 -4 3 2 1];
y=conv(h,x);
n=0:14;
subplot(2,1, 1);
stem(n,y);
xlabel('Time index n');ylabel(' Amplitude' );
title('Output Obtained by Convolution' );grid;
x1=[x zeros(1,8)];
y1=filter(h, 1,x1);
subplot(2,1, 2);
stem(n,y1);
xlabel('Time index n');ylabel(' Amplitude' );
title('Output Generated by Filtering'); grid;

Question 1: How do I determine the correct size of n?
Question 2: In x1=[x zeros(1,a)], what is the value of "a" in relation
to n,h and x? How do I compute "a"?

Thank you...I am new in DSP using Matlab.



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Convolution and Filtering - Amit Pathania - Jan 15 7:43:45 2007

to answer your first question:
   
  convolution results in n = length(x)+length(y) - 1 where x and y are one dimensional
vectors.
   
  about the 2nd question
  in matlab 'filter' results in an output with the same length as the input or filter whichever
is greater. if the input is shorter than the filter length zeros are appended(provided input
and filter start at 0 time index). 
   
  i think what you are doing is, making sure that when u compare the result of 'conv' and
'filter' ouputs, you get exactly same values as yor output. hope this helps

icpower2000 <i...@yahoo.com> wrote:
          Hi to all:

I have this program. My question is at the end of this program below.

clf;
h=[3 2 1 -2 1 0 -4 0 3];
x=[1 -2 3 -4 3 2 1];
y=conv(h,x);
n=0:14;
subplot(2,1,1);
stem(n,y);
xlabel('Time index n');ylabel('Amplitude');
title('Output Obtained by Convolution');grid;
x1=[x zeros(1,8)];
y1=filter(h,1,x1);
subplot(2,1,2);
stem(n,y1);
xlabel('Time index n');ylabel('Amplitude');
title('Output Generated by Filtering');grid;

Question 1: How do I determine the correct size of n?
Question 2: In x1=[x zeros(1,a)], what is the value of "a" in relation
to n,h and x? How do I compute "a"?

Thank you...I am new in DSP using Matlab.

Amit Pathania



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )