Convolution
显示 更早的评论
Hello everybody
Please,I want to do the convolution on my speech signal using conv() How can I do that??
This is my signal
f=8000;
b=8;
[s1,f,b]=wavread('C:\Users\N\Desktop\sara.wav');
5 个评论
Naz
2011-12-19
What do you want to convolve your signal with?
sara s
2011-12-19
Naz
2011-12-19
With a sinusoid of 8kHz? Something like modulation? Theoretically, if your voice contains frequencies over 4kHz you will have aliasing. Also, you need to choose how to truncate your sinusoidal signal (the length in time)
Naz
2011-12-19
Convolution with itself? Then just do conv(s1,s1)
sara s
2011-12-19
采纳的回答
更多回答(2 个)
Walter Roberson
2011-12-19
[conv(s1(:,1),s(:,1), 'same'), conv(s1(:,2), s1(:,2), 'same')]
That is for convolving each channel with itself. If for some reason you wanted to convolve left with right, then it would be
conv(s1(:,1), s1(:,2), 'same')
5 个评论
Naz
2011-12-19
Good point
sara s
2011-12-19
sara s
2011-12-19
Walter Roberson
2011-12-19
Please show the traceback of the error -- which line of code it occurred in, which routine, where it was called from, and so on.
Timothy Dixon
2012-5-18
@ sara correct the type error from walter conv(s1(:,1),s(:,1)
correction
conv(s1(:,1),s1(:,1),
s1 was missing. if it does not work, then try to upgrade the version of Matlab that support the recording card system
Image Analyst
2011-12-19
How about:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 24;
fullFileName = 'C:\Users\N\Desktop\sara.wav';
if exist(fullFileName, 'file')
[s1,f,b]=wavread(fullFileName);
subplot(2,1,1);
plot(s1);
grid on;
title('Original Signal', 'FontSize', fontSize);
windowSize = 201; % or whatever.
s1_filtered = conv(s1, ones(1, windowSize ) / windowSize );
subplot(2,1,2);
plot(s1_filtered);
grid on;
title('Filtered Signal', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
else
message = sprintf('File not found:\n%s', fullFileName);
uiwait(warndlg(message));
end
17 个评论
Walter Roberson
2011-12-19
I suspect Sara's wave file is two channel.
Naz
2011-12-19
I suspect Sara gave up...
sara s
2011-12-19
Naz
2011-12-19
Maybe his concern is in wording of convolution OF two signal with convolution BETWEEN two signals, but in the case of recorded voice, I would say it is very possible to perform convolution (with itself or any other real signal).
sara s
2011-12-19
Walter Roberson
2011-12-19
That code looks like it should do convolution of the two channels against themselves. I have no idea what the mathematical result of that is expected to be, or what it would sound like.
Usually you would convolve against a much smaller vector to achieve a filter, such as convolving against [-1/2 1 -1/2] to get a variety of moving average.
There is probably a nice fourier analysis for what convolving a signal against itself would do, but I do not know what that analysis would be. Squaring all the frequency components, maybe ??
Naz
2011-12-19
I just updated my answer
Naz
2011-12-19
@Walter. Squaring of frequency spectrum
sara s
2011-12-19
sara s
2011-12-19
Walter Roberson
2011-12-19
Wouldn't you need to square (the number of samples divided by 2) in order to square the frequency spectrum, if by that you mean that if you had 2*N+1 frequency bins in the fft before, that the new fft would have 2*(N^2)+1 bins and the new maximum frequency would be in bin N^2+1 ?
Bjorn Gustavsson
2011-12-19
@Walter, convolving a signal with itself should give something close to the autocorrelation function - and that would be the Fourier transform of the power spectra.
Image Analyst
2011-12-19
sara: Naz suggested that you'd want to convolve the signal with itself. I suggested just a box filter (local averaging) as an illustration. But YOU haven't yet said what is to be convolved with your signal. You also haven't said anything about needing frequencies, spectrum, Fourier analysis, or anything like that. Do you need anything like that or is any old signal convolved with your s1 good enough to complete your assignment?
sara s
2011-12-19
sara s
2011-12-19
Walter Roberson
2011-12-19
There are a number of different filters shown at http://web.mit.edu/1.130/WebDocs/1.130/Software/Examples/example1.m
In that code, you want the vectors that are directly underneath each comment. For example the line under '%Downsampling' is
x = [-1 0 9 16 9 0 -1] / 16;
and that x would be suitable to convolve against.
sara s
2011-12-20
类别
在 帮助中心 和 File Exchange 中查找有关 Digital Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!