MATLAB: Error using ==> times Matrix dimensions must agree.

vector matrix length

When I am executing this program, I got the error message
??? Error using ==>times Matrix dimensions must agree.
all i need to have is a signal that i will plot after multiplying the h vector and x input signal .
even with the same length , i couldn't find the problem
%generation de la reponse impultionnelle
h=[ zeros(1 ,480) -436 -829 -2797 -4208 -17968 -11215 46150 34480 -10427 9049 -1309 -6320 390 -8191 -1751 -6051 -3796 -4055 -3948 -2557 -3372 -1808 -2259 -1300 -1098 -618 -340 -61 323 419 745 716 946 880 1014 976 1033 1091 1053 1042 794 831 899 716 390 313 304 304 73 -119 -109 -176 -359 -407 -512 -580 -704 -618 -685 -791 -772 -820 -839 -724 zeros(1 , 480)]
figure, plot(h)
axis([ 0 1024 -30000 50000]);
xlabel('amp');
ylabel('pnt');
title('reponse impulsionnelle ');
set(gcf, 'Color', [1 1 1])
%creation du signal far-end
[x,fs]=wavread('Alarm01.wav');
t=linspace(0,length(x)/fs,length(x)); % creation du vecteur temps
plot(t,x)
figure, plot(h)
Nfft=1024; %longueur du vecteur frequence
f=linspace(0,fs,Nfft);
G=abs(fft(x,Nfft));
figure ; plot(f(1:Nfft/2),G(1:Nfft/2),'g')
y=h'.*G.
plot(y)

Best Answer

Your vector t is a row vector, that is, presumably 1 by 1024 in size. If there is no complaint in plot(t,x), then x must also be 1 by 1024, which in turn means that G is 1 by 1024. However the vector h' is 1024 by 1, and that would produce an error in the multiplication y = h'.*G . You should insert size(h') and size(G) just before that multiplication to verify this.