Need help in converting Matlab Code to Java Code

I have java code which gives me FFT output from real inputs. I need to perform MCLT. Currently I have the FFT output with me in the following format. I have seen some fast MCLT alogrithm (https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr-2005-02.pdf), coded in Matlab, but can not understand it perfectly. Can someone help me in writing corresponding java code.
Java Code:
int dtLength = data.length/2;
double[] realPart = new double[dtLength];
double[] imagPart = new double[dtLength];
Matlab Code:
function X = fmclt(x)
% FMCLT - Compute MCLT of a vector via double-length FFT
%
% H. Malvar, September 2001 -- (c) 1998-2001 Microsoft Corp.
%
% Syntax: X = fmclt(x)
%
% Input: x : real-valued input vector of length 2*M
%
% Output: X : complex-valued MCLT coefficients, M subbands
% in Matlab, by default j = sqrt(-1)
% determine # of subbands, M
L = length(x);
M = L/2;
% normalized FFT of input
U = sqrt(1/(2*M)) * fft(x);
% compute modulation function
k = [0:M]';
c = W(8,2*k+1) .* W(4*M,k);
% modulate U into V
V = c .* U(1:M+1);
% compute MCLT coefficients
X = j * V(1:M) + V(2:M+1);
return;
% Local function: complex exponential
function w = W(M,r)
w = exp(-j*2*pi*r/M);
return;

Answers (0)

Categories

Asked:

on 3 May 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!