function B = FOU_CHB(A,direction) % A - original data in columns % B - transformed data in columns % direction - set equal to 1 for nodal to spectral % anything else for spectral to physical [N,~] = size(A); if direction==1 % physical-to-spectral A = flipud(A);% TO FOLLOW THETA DIRECTION F=ifft([A(1:N,:);A(N-1:-1:2,:)]); B=([F(1,:); 2*F(2:(N-1),:); F(N,:)]); else % Spectral-to-physical F=fft([A(1,:); [A(2:N-1,:);2*A(N,:);A(N-1:-1:2,:)]/2]); B = real(F(N:-1:1,:)); end