Question
I have this program but Im getting this error Index exceeds the number of array elements (1).Could you help me to fix it please. function
I have this program but Im getting this error Index exceeds the number of array elements (1).Could you help me to fix it please.
function y = overlap_add(x,h,lc)
M=length(h); % number of elements in h
N=length(x); % number of elements n x
r=rem(N,lc); % remainder when N is divided by lc
x1=[x zeros(1,lc-r)]; % add lc-r zeros at the end of array x
n1=length(x1)/lc; %length of x1 divided by lc
h1=[h zeros(1,lc-1)]; % add lc-1 zeros at the end of h
for j=1:n1
Matrix1(j,:)=x1(((j-1)*lc+1):j*lc); % Matrix1 is formed by taking lc samples from x1 for each row
Matrix2(j,:)=[Matrix1(j,:) zeros(1,M-1)]; % Matrix2 is formed by adding M-1 zeros at the end of Matrix1 for each row
Matrix3(j,:)=ifft(fft(Matrix2(j,:)).*fft(h1)); % % Circular convolution of Matrix2 and h1 to get Matrix3 row by row
Matrix4(j,:)=[zeros(1,(j-1)*lc) Matrix3(j,:) zeros(1,(n1-j)*lc)]; % adding zero at the beginning and end at each row of Matrix3
end
y =sum(Matrix4); % y is obtained by summing each column of Matrix4
i=1:M+N-1;
y=y(i);
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started