Home > atmlab > randomize > iaaft > fourier_coeff_isotrop.m

fourier_coeff_isotrop

PURPOSE ^

SYNOPSIS ^

function output_coeff = fourier_coeff_isotrop(x)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

fourier_coeff_isotrop.m

SOURCE CODE ^

0001 function output_coeff = fourier_coeff_isotrop(x)
0002 
0003 [y_size x_size] = size(x);
0004 if ( (y_size == 1) | (x_size == 1) ) % input is a 1D power spectrum that has to be made 2D
0005     output_coeff = fourier_coeff_isotroph_sub(x);
0006 else                                 % input is a 2D power spectrum that has to be made 3D by a cylinder rotation
0007     output_coeff = zeros(x_size, x_size, y_size); % the y_size of the old 2D matrix is the z_size of the 3D matrix
0008     for j = 1:y_size
0009         xx = x(j, :);
0010         temp = fourier_coeff_isotroph_sub(xx);
0011         output_coeff(:, :, j) = temp;
0012     end
0013 end
0014 
0015 
0016 function a=fourier_coeff_isotroph_sub(x)
0017 % This function makes a 2D power spectrum out of a 1D one
0018 % Assumption is isotrophy.
0019 
0020 ori_vector_size = length(x);
0021 ori_half_size   = ori_vector_size/2;
0022 a = zeros(ori_vector_size); % The 2D Fourier matrix
0023 
0024 for t1 = 1:ori_half_size+1
0025     for t2 = 1:ori_half_size+1
0026         index = 1 + round(  sqrt( (t1-1)^2 + (t2-1)^2 )  );
0027         if ( index > ori_half_size + 1 )
0028             index = ori_half_size + 1;
0029         end
0030         t3 = 2 + ori_vector_size - t1;
0031         if ( t3 > ori_vector_size ) 
0032             t3 = t1;
0033         end
0034         t4 = 2 + ori_vector_size - t2;
0035         if ( t4 > ori_vector_size ) 
0036             t4 = t2;
0037         end
0038         if ( index > 1 )
0039             coeff = x(index) / sqrt(index-1); % index-1 is the radius of the circel
0040         else
0041             coeff = x(index); % x(1); the DC-component of the Fourier spectrum should be zero anyway.
0042         end        
0043         a(t1,t2) = coeff;
0044         a(t3,t2) = coeff;
0045         a(t1,t4) = coeff;
0046         a(t3,t4) = coeff;
0047     end
0048 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005