1
votes

i've been trying to do this question but no matter how i go about it i get this error.

any ideas ?

The question is

enter image description here

"Matrix dimensions must agree"

bb = [1,1.18,1]; %-- Filter Coefficients
nn = 1:150;
L2 = 0:9; % M - 1(10-1 = 9)

%1st at 0.3
w1 = (0.2*cos(0.44*pi*nn)) .* (exp(-1i * 0.3 * 3.14 * L2)) ;

%2nd at 0.44
w2 = 0.2*cos(0.44*pi*nn) .* exp(-1i*0.44*3.14*L2);

%3rd at 0.7
w3 = 0.2*cos(0.44*pi*nn) .* exp(-1i*0.7*3.14*L2);

wt = w1 + w2 + w3;

HTOTAL = freqz(bb, 1, wt); 

H1 = freqz(bb, 1, w1); %

H2 = freqz(bb, 1, w2); %

H3 = freqz(bb, 1, w3); %

%set the value of x to see the filter
x = 1;

subplot(2,1,1); plot(wx, abs(HH))
subplot(2,1,2); plot(wx, angle(HH))
xlabel('Normalized Radian Frequency')
1

1 Answers

0
votes

You're trying to element-wise multiply (0.2*cos(0.44*pi*nn)) by (exp(-1i*0.3*3.14*L2)). The issue here is that the first array contains nn = 150 elements, while the second contains L2 = 10 elements.

Looking at the original question, it looks like you're required to use a filter length (L2) of 10, but your nn array ranges from 1 to 150 instead of the required 0 to 9.

You should use (0.2*cos(0.44*pi*L2)) instead of (0.2*cos(0.44*pi*nn)) to fix your "Matrix dimensions must agree" error.