Convolution

조회 수: 12 (최근 30일)
sara s
sara s 2011년 12월 19일
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일
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일
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
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일
[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
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일
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일
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

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

카테고리

Help CenterFile Exchange에서 Digital Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by