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
Naz 2011년 12월 19일
What do you want to convolve your signal with?
sara s
sara s 2011년 12월 19일
I know the convolution must be with something
But my prof ask me to do convolution only for speech signal and for that I'm confused
Naz
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
Naz 2011년 12월 19일
Convolution with itself? Then just do conv(s1,s1)
sara s
sara s 2011년 12월 19일
Yes,I did that previously
But I have this error
??? Error using ==> conv at 27
A and B must be vectors.

댓글을 달려면 로그인하십시오.

 채택된 답변

Naz
Naz 2011년 12월 19일

1 개 추천

First of all, this
f=8000;
b=8;
is useless information because it will be rewritten anyway below, unless this information is given to you and you don't fully describe the required task. ASSUMING that your professor wants you to perform convolution of the recorded signal with itself, you can perform this:
[s1,f]=wavread('C:\Users\N\Desktop\family.wav');
s2 = conv(s1(1,:),s1(1,:)); %using all columns from the first row
subplot(2,1,1)
plot(s1(1,:))
subplot(2,1,2)
plot(s2)
Of course, the resulting signal will be nothing like the initial signal.

댓글 수: 3

sara s
sara s 2011년 12월 19일
I have this error
??? Error using ==> conv at 27
A and B must be vectors.
Naz
Naz 2011년 12월 19일
Try replacing both s1 with s1'
Walter Roberson
Walter Roberson 2011년 12월 19일
Sara has a two-channel wav file so s1 is not a vector.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 12월 19일

1 개 추천

[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
Naz 2011년 12월 19일
Good point
sara s
sara s 2011년 12월 19일
Thanks
But when I want to plot it,Nothing appear
sara s
sara s 2011년 12월 19일
I have this error
??? Error: An array for multiple LHS assignment cannot contain numeric value.
Walter Roberson
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
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
Image Analyst 2011년 12월 19일

1 개 추천

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
Walter Roberson 2011년 12월 19일
I suspect Sara's wave file is two channel.
Naz
Naz 2011년 12월 19일
I suspect Sara gave up...
sara s
sara s 2011년 12월 19일
No, I'm not give up, but do you think it's true
Because when I asked my prof,he said that is not possible to make convolution between two signals and I'm confused from the information of my prof,all his information make me feel bother
Naz
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
sara s 2011년 12월 19일
so I did that and do you think it's true
f=8000;
b=8;
[s1,f,b]=wavread('C:\Users\N\Desktop\family.wav');
s2 = zeros(size(s1));
for j1 = 1:size(s1,2)
s2(:,j1) = conv(s1(:,j1),s1(:,j1),'same');
end
plot(s2)
sound(s2,f)
Walter Roberson
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
Naz 2011년 12월 19일
I just updated my answer
Naz
Naz 2011년 12월 19일
@Walter. Squaring of frequency spectrum
sara s
sara s 2011년 12월 19일
@Walter,Yes also I think that
sara s
sara s 2011년 12월 19일
Thanks so so much Walter and Naz
Walter Roberson
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
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
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
sara s 2011년 12월 19일
Thanks a lot Image Analyst,that is enough for me :)
sara s
sara s 2011년 12월 19일
and I just wanted to make convolve the signal with it self and that is enough for me and Thanks a lot Image Analyst,you are very good
Walter Roberson
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
sara s 2011년 12월 20일
wow Walter thanks so so much ,that is so benefit
Thanks a lot

댓글을 달려면 로그인하십시오.

카테고리

태그

질문:

2011년 12월 19일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by