MATLAB Answers

sara s


Asked by sara s
on 19 Dec 2011
Accepted Answer by Naz

Hello everybody

Please,I want to do the convolution on my speech signal using conv() How can I do that??

This is my signal





on 19 Dec 2011

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)

on 19 Dec 2011

Convolution with itself? Then just do conv(s1,s1)

sara s
on 19 Dec 2011

Yes,I did that previously

But I have this error

??? Error using ==> conv at 27

A and B must be vectors.


No products are associated with this question.

3 Answers

Answer by Naz
on 19 Dec 2011
 Accepted answer

First of all, this


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:

s2 = conv(s1(1,:),s1(1,:)); %using all columns from the first row

Of course, the resulting signal will be nothing like the initial signal.


sara s
on 19 Dec 2011

I have this error

??? Error using ==> conv at 27

A and B must be vectors.

on 19 Dec 2011

Try replacing both s1 with s1'

Sara has a two-channel wav file so s1 is not a vector.

Answer by Walter Roberson
on 19 Dec 2011

[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')


sara s
on 19 Dec 2011

I have this error

??? Error: An array for multiple LHS assignment cannot contain numeric value.

Please show the traceback of the error -- which line of code it occurred in, which routine, where it was called from, and so on.

@ sara correct the type error from walter conv(s1(:,1),s(:,1)


s1 was missing. if it does not work, then try to upgrade the version of Matlab that support the recording card system

Answer by Image Analyst
on 19 Dec 2011

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')
	grid on;
	title('Original Signal', 'FontSize', fontSize);
	windowSize = 201; % or whatever.
	s1_filtered = conv(s1, ones(1, windowSize ) / windowSize );
	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') 
	message = sprintf('File not found:\n%s', fullFileName);


sara s
on 19 Dec 2011

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

There are a number of different filters shown at

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
on 20 Dec 2011

wow Walter thanks so so much ,that is so benefit
Thanks a lot

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!