Educational materials

Supplemental Notes - Fall 07 - EG 10111 - Lecture 8

Unit Testing for checkCollision function

checkCollision(0,0,5,7,3,4,20,10)
checkCollision(0,0,5,7,10,4,20,10)
checkCollision(12,7,5,7,3,4,20,10)

computeDCT function

function y = computeDCT(InArray,ArraySize)
% Assume k, ArraySize, InArray defined elsewhere
%   i = Index variable
%   InArray = Input array x
%   ArraySize = Size of the array -> N
%   k = which element we are computing the result for
for k=1:SizeArray
  sum = 0;  for i=1:SizeArray     sum = sum + InArray(i)*cos((pi()*(2*i-1)*(k-1)/(2*ArraySize));
  end
  y(k) = sum;
end % Taking the result from the first for loop
for k=1:SizeArray
  if k == 1
    y(k) = y(k) * (1 / sqrt(SizeArray));
  else
    y(k) = y(k) * sqrt(2 / SizeArray);
  end
end
r1 - 16 Nov 2007 - 17:29:39 - AaronStriegel
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Syndicate this site RSSATOM