Calculate the 1D DCT of signal x[n]=[1, 2, 3, 4]
% Matlab Code
y=[1,2,3,4];
[M,N]=size(y);
sum=0;
dct1d=zeros(1,N);
u=[0:N-1] ;
for j=1:N
for i=1:N
sum = sum + y(i).*(cos((pi.*(2.*u(i)+1).*u(j))/(2*N)));
end
if j==1
K=sqrt(1/N);
else
K=sqrt(2/N);
end
dct1d(j)=K.*sum;
sum=0;
end
dct1d
Output Snapshot:
Get Answers For Free
Most questions answered within 1 hours.