MATLAB: What must i do to fix it

chirp

I keep getting an error that says "Matrix dimensions must agree." while running this code.Please suggest me some options to fix this error.
%chirp generation (430-470KHZ)
fs=450e4;
pulsewidth =0.0004;
i=1/fs;
t =0:i:pulsewidth;
f0=430e3;
f1=470e3;
x=chirp(t,f0,pulsewidth,f1);
plot(x)
figure(1)
title('Chirp Signal');
ylabel('Amplitude')
xlabel('Time');
% generating white gaussian noise
l=1401;
mu=0;
sigma=.0001;
noise=sigma*randn(1,l)+mu;
N=length(x);
intf = int16(zeros(1,N)); % 'f'-integer type
% flipping
for d = 1:1:N
intf(d) =x(N-d+1);
end
F=length(intf);
% generating noisy signal
y=[zeros(1,200),x,zeros(1,200)]+noise;
n=length(y);
for j=1:1:n
y(j)=y(j)*1000;
end
Y=int16(y);
N=length(Y);
subplot(4,1,2)
plot(y)
figure(2)
% creating convoluted product array
r=zeros(1,1601);
R=int16(r);
M=length(R);
%convlution
for k=1:1:N-F
s=0;
for q=1:1:F
s=s+(Y(k+q)*intf(q));
end
R(k)=int16(s);
end
subplot(4,1,3)
plot(R)

Best Answer

The error is in this line:
% generating noisy signal

y=[zeros(1,200),x,zeros(1,200)]+noise;
The problem is that this part of the expression:
[zeros(1,200),x,zeros(1,200)]
is size (1x2201), and ‘noise’ is (1x1401).
One way to fix it is:
% generating noisy signal
y=[zeros(1,200),x,zeros(1,200)];
y = y + sigma*randn(1,numel(y))+mu;
Experiment to get the result you want.