%------------------------------------------------------------------------ % NAME: h_weights_integr % % Determines weights for performing an integration as a matrix % multiplication. With other words: % We want to calculate the integral of the product of G and H % by a vector multiplication as W*G % The function H is known, but G is unknown. % Both G and H are assumed to be linear between the grid points % % FORMAT: w = h_weights_integr(fg,fh,h) % % RETURN: w matrix weights % IN: fg position (e.g. frequency) of values of G % fh position of values of H % h values of the H function (at fh) %------------------------------------------------------------------------ % HISTORY: 12.11.99 Created for Skuld by Patrick Eriksson. % 25.08.00 Adapted to AMI by Patrick Eriksson function w = h_weights_integr(fg,fh,h) %=== Main sizes ng = length(fg); nh = length(fh); w = zeros(1,ng); %=== Check input if ( length(h) ~= nh ) error('Lengths integration grid and function do not match'); end %=== Init index and loop until freqs. of G are inside freqs. of H ig = 1; ih = 1; while ( (ig